-
Label Box
I have a wondering here. This code I have below is working great except of one thing that doesn´t make sense to me.
I use a while-loop inside a for-loop as seen.
The for-loop is counting from 1-49 and for each count the while-loop will read a .txt file and put some info to a file.
Notice now in my code in the for-loop that I have put "Display this" to a label on my form.
This should be shown for the first count in the foor-loop wich is 1 ?
What happens in this code is that "Display this" will be shown First when the count is ready, wich then is count = 49.
Why is this happening. It should be shown directly and not in the end of the loop ?
HowEver if I put this message box in the same place instead of "Label1" then it will
Display a new messagebox for each count wich meens 49 MessageBoxes
Code:
MessageBox::Show("Display this");
Code:
std::string Line;
ofstream MainFile;
MainFile.open ("Main.txt");
for (int count= 1; count < (50); count++)
{
Label1->Text = "Display this";
ifstream File ("DGD.txt");
while ( getline(File, Line, '\n') )
{
MainFile << "Hello" << ',' << "Hello2" << '\n';
}
}
-
The form is only updated during a paint message. If you invalidate the form right after the "Display this" statement it should change each loop iteration. Of course if you put the same text in the same place you won't notice.
-
Okay, I am not sure how to do that. You meen that I will put some code the line under this line in order to invalidate the form ?
Code:
Label1->Text = "Display this";
-
The way I've done it, in MFC, is :
// Invalidate the label
label->Invalidate();
// tell it to paint
SendMessage(WM_PAINT);
Assuming label is a pointer to a static control or something similar.
But this can cause excessive flicker in the application.
-
Ok, I have tried to put it like this, It does compile but it doesn´t work. If I also put the line SendMessage(WM_PAINT); under the ->Invalidate(), I will have a compiler Error that says:
WM_PAINT undeclared identifier.
I dont know what is nesscary to do. Do I have to declare something or #include anything.
Thanks...
Code:
CurrentSymbol->Text = "Display this";
CurrentSymbol->Invalidate();
-
Why not post in C# when you're using it? Windows subforum is more for... native programming.
-
Yes I will do that instead, thanks :)