With this code I will show a message box that you can press Yes or No.
What happens when pressing Yes is that a panel will be Visible. On this panel, I have a label that shows text and a progressbar that will go from Value 0-100, like the code below.

The problem is that when the panel gets "Visible", the label that show text will not.
The label that shows text will be seen first when the progressbar have reached Value = 100.

I wonder how it could be possible to see the text "While" or practically before the progressbar begin it´t process ?

Is there any function that can make something wait or pause for 1 second. I have heard something about "Sleep" or "Pause".
That could be useful for many things perheps ?

System::Windows::Forms::DialogResult result = MessageBox::Show(this, "Hello", MessageBoxButtons::YesNo, MessageBoxIcon::Question);
		 

if (System::Windows::Forms::DialogResult::Yes == result)
{
       panel3->Visible = true;
}
			 
 if (System::Windows::Forms::DialogResult::Yes == result)
{
        for(double i = 1; i < 100000005; i++)
        {
	 progressBar2->Value = i / 1000000;
        }
}

I have tried to put Thread:: Sleep(1000) between the "operations".
The problem that occurs is that after the messagebox dissapear and will show the panel with a label with some text, this happens:

1. The messageBox doesn´t dissapear enterily until the progressbar is finished.
2. The Text that the label contains on the panel will first show after the progressbar is finished.

I tried to put Thread:: Sleep(1000) between if some time was needed inbetween, but this does not solve this scenario.

System::Windows::Forms:: DialogResult result = MessageBox::Show(this, "Hello", MessageBoxButtons::YesNo, MessageBoxIcon::Question);

Thread::Sleep(1000);		 

if (System::Windows::Forms::DialogResult::Yes == result)
{
       panel3->Visible = true;
}

Thread:: Sleep(1000);
			 
 if (System::Windows::Forms::DialogResult::Yes == result)
{
        for(double i = 1; i < 100000005; i++)
        {
	 progressBar2->Value = i / 1000000;
        }
}

Perhaps you need to update the label text as you update the progress bar value...in the same iteration...

That didn´t seem to work either. I have simplified the code a bit.
The first thing that should happen is that when pressing yes on the messagebox, the
panel3 will show and on this panel I have a label72 that says. "Text"

Then I will Delay with 1 second and label72 should be "" and label73 will show "Other Text"
Then again Delay with 1 second and then the panel3 will be Visible = false;


The only thing that happens when pressing "Yes" is that the panel3 will be Visible, but none of the Text:s will be seen. Also the MessageBox(YesNo) is still in the background almost dissapeard.
It seems that things go to fast that the Textlabels doesn´t "have time" to show and the MessageBox doesn´t have time to completely dissapear ?

System::Windows::Forms::DialogResult result = MessageBox::Show(this, "Hello", "Hello2", MessageBoxButtons::YesNo, MessageBoxIcon::Question);
		 
			 
if (System::Windows::Forms::DialogResult::Yes == result)
{
        panel3->Visible = true;
        label72->Visible = true;

			 
	Thread::Sleep(1000); //Delays with ca 1 second
	 label72->Text = "";
	 label73->Text = "Other Text";

	Thread::Sleep(1000); //Delays with ca 1 second
	panel3->Visible = false;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.