Why in this code the form *does not refresh* when it gets the focus/after some time?
#using <mscorlib.dll >
#using <system.windows .forms.dll>
#using <system.dll>
#using <system.drawing .dll>
#include <windows.h>
#include <cstdlib>
// ==> Just a Form with two labels, one progress bar, opacity 90%.
// ==> label1, and progressBar are public and accessed through main().
// ==> Placed some refreshes but the problem persists.
__gc class Form1: public System::Windows ::Forms::Form
{
private:
System::Windows ::Forms::Label * label2;
public:
System::Windows ::Forms::Progre ssBar * progressBar1;
System::Windows ::Forms::Label * label1;
Form1()
{
this->label2 = new System::Windows ::Forms::Label( );
this->progressBar1 = new System::Windows ::Forms::Progre ssBar();
this->label1 = new System::Windows ::Forms::Label( );
this->label2 = new System::Windows ::Forms::Label( );
this->progressBar1 = new System::Windows ::Forms::Progre ssBar();
this->label1 = new System::Windows ::Forms::Label( );
this->SuspendLayout( );
this->label2->Font = new System::Drawing ::Font(S"Micros oft Sans Serif", 9.75F,
System::Drawing ::FontStyle::Re gular, System::Drawing ::GraphicsUnit: :Point, (System::Byte)1 61);
this->label2->Location = System::Drawing ::Point(14, 16);
this->label2->Name = S"label2";
this->label2->Size = System::Drawing ::Size(264, 40);
this->label2->TabIndex = 1;
this->label2->Text = S"Message 1...";
this->label2->TextAlign = System::Drawing ::ContentAlignm ent::MiddleCent er;
this->progressBar1->Location = System::Drawing ::Point(10, 176);
this->progressBar1->Name = S"progressBar1" ;
this->progressBar1->Size = System::Drawing ::Size(272, 23);
this->progressBar1->TabIndex = 2;
this->label1->Font = new System::Drawing ::Font(S"Micros oft Sans Serif", 8.25F,
System::Drawing ::FontStyle::Re gular, System::Drawing ::GraphicsUnit: :Point, (System::Byte)1 61);
this->label1->Location = System::Drawing ::Point(14, 80);
this->label1->Name = S"label1";
this->label1->Size = System::Drawing ::Size(264, 64);
this->label1->TabIndex = 3;
this->AutoScaleBaseS ize = System::Drawing ::Size(5, 13);
this->ClientSize = System::Drawing ::Size(292, 271);
this->Controls->Add(this->label1);
this->Controls->Add(this->progressBar1 );
this->Controls->Add(this->label2);
this->FormBorderStyl e = System::Windows ::Forms::FormBo rderStyle::Fixe d3D;
this->Name = S"Form1";
this->Opacity = 0.9;
this->ShowInTaskba r = false;
this->Text = S"Some Application";
this->TopMost = true;
this->ResumeLayout(f alse);
}
};
int main()try
{
Form1 *pForm1= __gc new Form1;
pForm1->Show();
pForm1->Refresh();
pForm1->label1->Text= "Diagnostic code";
pForm1->progressBar1->Value= 0;
pForm1->progressBar1->Maximum= 100;
while(true)
{
for(long i= 0; i< 100; ++i)
{
pForm1->progressBar1->Increment(1) ;
pForm1->Refresh();
}
pForm1->progressBar1->Value= 0;
}
}
catch(System::E xception *pe)
{
using namespace System;
Console::WriteL ine("Error: {0}", pe->Message);
return EXIT_FAILURE;
}