This code makes sense to me, I'm just having trouble trying to understand why it doesn't work correctly. This is a GUI APP. When the Play button is Clicked, the play_Click(Syst em::Object * sender, System::EventAr gs * e) function is called, it is suppose to make the Play button dissapear and the Pause Button Appear as soon as the Play button is clicked. I don't know why it calls the keystrokes function then goes through the while loop continuously without ever displaying the Pause Button, instead of making the Play dissapear and the Pause appear then goto the keystrokes function which will finally go through the while loop. I also had conditions where it would go through the file once, then stop, then display the Pause Button.
My objective is to Play, Pause whenever the user wants. When Play is clicked, the Play button should dissapear and the Pause Button should appear. When the Pause button is clicked, the pause button should dissapear and the Play button should appear. That way the user can Play and Pause the file iteration at ANY point in time. -
-
private: System::Void keystrokes(System::Object * sender, System::EventArgs * e)//, char *array)
-
{//actual key presses depending on the characters read
-
-
char array[255];
-
-
ifstream in;
-
-
in.open("c:\\write.txt", ios::in);
-
-
-
if(!in)
-
{
-
richTextBox1->AppendText("\nCannot open input file.\n");
-
return;
-
}
-
-
while(in) //&& keystrokeFlag == true)
-
{
-
if(playFlag == false)
-
{
-
richTextBox1->AppendText("\nBreak\n");
-
break;
-
}
-
-
richTextBox1->AppendText("\nGetline\n");
-
in.getline(array, 4); //delim defaults to '\n'
-
-
richTextBox1->AppendText("\nPush Keystrokes\n");
-
pushKeystrokes(sender, e, array);
-
-
richTextBox1->AppendText("\nCheck Status\n");
-
checkStatus(sender, e);
-
-
richTextBox1->AppendText("\nSleep Timer\n");
-
System::Threading::Thread::Sleep(100);
-
-
if(in.eof())
-
{
-
richTextBox1->AppendText("\nEND OF FILE\n");
-
in.clear(); //clear the flags (in.seekg() will not work properly without this function call)
-
in.seekg(0, ios::beg); //infinite loop work on this tomorrow
-
}
-
-
}
-
in.close(); //close document
-
}
-
-
private: System::Void checkStatus(System::Object * sender, System::EventArgs * e)
-
{
-
richTextBox1->SelectionColor = Color::LimeGreen; //color indication testing purposes
-
if(play->Visible == true)
-
{
-
richTextBox1->AppendText("FALSE\n");
-
playFlag = false;
-
}
-
if(play->Visible == false)
-
{
-
richTextBox1->AppendText("TRUE\n");
-
playFlag = true;
-
}
-
}
-
-
private: System::Void play_Click(System::Object * sender, System::EventArgs * e)
-
{
-
play->Visible = false;
-
pause->Visible = true;
-
-
keystrokes(sender, e);
-
}
-
-
private: System::Void pause_Click(System::Object * sender, System::EventArgs * e)
-
{
-
pause->Visible = false;
-
play->Visible = true;
-
-
keystrokes(sender, e);
-
}
-
-
0 919 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Lee Garrington |
last post by:
Hello,
Basically this is my problem. I am programming minesweeper in java. I have
a panel in the background on which I draw all the mines/numbers etc. and
then I have an array of buttons that sit on top of them.
I am developing a solver and need a pause between each move the algorithm
makes. I know from my past experience that you have to use something along
the lines of :-
|
by: Griff |
last post by:
#include <iostream>
using namespace std;
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
template<class C>void PrintAll(C&v)
{
|
by: Matthias Kaeppler |
last post by:
Hello,
I am having trouble getting std::equal_range to perform as I wish, and I
can't find my error.
Here's the situation:
I have a vector of pointers to filesystem path objects (a file list,
basically). This vector is partitioned each time the file list was
rebuilt into paths which are directories and paths which are not. The
directories comes first.
|
by: Bonj |
last post by:
I was in need of an encryption algorithm to the following requirements:
1) Must be capable of encrypting strings to a byte array, and decyrpting
back again to the same string
2) Must have the same algorithm work with strings that may or may not be
unicode
3) Number of bytes back must either be <= number of _TCHARs in *
sizeof(_TCHAR), or the relation between output size and input size can be
calculated simply. Has to take into account the...
|
by: 2obvious |
last post by:
I have a DataGrid containing a TextBox control and a CustomValidator
in each row. The CustomValidator fires a function that compares all
TextBoxes for equality. The algorithm for comparison is
straightforward:
*PSEUDOCODE*
for i=1 thru ( Container.Length-1 )
for j=i+1 thru ( Container.Length-1 )
if ( TextBox==TextBox )
| |
by: Julio C. Hernandez Castro |
last post by:
Dear all,
We have just developped a new block cipher called Raiden, following a
Feistel Network structure by means of genetic programming. Our
intention now consists on getting as much feedback as possible from
users, so we encourage you to test the algorithm and send us your
opinion. We would also like to receive enhancements and new versions of
the algorithm, developed in other source languages and platforms.
Our idea on developing...
|
by: aruna |
last post by:
hey guys i earlier had very valuable responses from you all for base64
encoding algorithm.so thank for that. so now i need your assistance to
do a float encoding algorithm. you may wonder why i'm so interest
about this encoding algorithms. because our group is going to do a
project under the ITU-T Recommendation X.891. this is named as fast
infoset. this is an open source project in c language. there is an
implementation in java which by...
|
by: Dick Moores |
last post by:
I'm writing a demo of the infinite series
x**0/0! + x**1/1! + x**2/2! + x**3/3! + ... = e**x (x is non-negative)
It works OK for many x, but for many the loop doesn't break. Is there
a way to get it to break where I want it to, i.e., when the sum
equals the limit as closely as the precision allows?
Here's what I have:
|
by: Nick Keighley |
last post by:
Hi,
this is cut from a larger program.
<code>
#include <algorithm>
#include <vector>
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |