I
Ioannis Vranos
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:rogressBar * progressBar1;
System::Windows::Forms::Label * label1;
Form1()
{
this->label2 = new System::Windows::Forms::Label();
this->progressBar1 = new System::Windows::Forms:rogressBar();
this->label1 = new System::Windows::Forms::Label();
this->label2 = new System::Windows::Forms::Label();
this->progressBar1 = new System::Windows::Forms:rogressBar();
this->label1 = new System::Windows::Forms::Label();
this->SuspendLayout();
this->label2->Font = new System:rawing::Font(S"Microsoft Sans Serif", 9.75F,
System:rawing::FontStyle::Regular, System:rawing::GraphicsUnit:oint, (System::Byte)161);
this->label2->Location = System:rawing:oint(14, 16);
this->label2->Name = S"label2";
this->label2->Size = System:rawing::Size(264, 40);
this->label2->TabIndex = 1;
this->label2->Text = S"Message 1...";
this->label2->TextAlign = System:rawing::ContentAlignment::MiddleCenter;
this->progressBar1->Location = System:rawing:oint(10, 176);
this->progressBar1->Name = S"progressBar1";
this->progressBar1->Size = System:rawing::Size(272, 23);
this->progressBar1->TabIndex = 2;
this->label1->Font = new System:rawing::Font(S"Microsoft Sans Serif", 8.25F,
System:rawing::FontStyle::Regular, System:rawing::GraphicsUnit:oint, (System::Byte)161);
this->label1->Location = System:rawing:oint(14, 80);
this->label1->Name = S"label1";
this->label1->Size = System:rawing::Size(264, 64);
this->label1->TabIndex = 3;
this->AutoScaleBaseSize = System:rawing::Size(5, 13);
this->ClientSize = System:rawing::Size(292, 271);
this->Controls->Add(this->label1);
this->Controls->Add(this->progressBar1);
this->Controls->Add(this->label2);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->Name = S"Form1";
this->Opacity = 0.9;
this->ShowInTaskbar = false;
this->Text = S"Some Application";
this->TopMost = true;
this->ResumeLayout(false);
}
};
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::Exception *pe)
{
using namespace System;
Console::WriteLine("Error: {0}", pe->Message);
return EXIT_FAILURE;
}
#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:rogressBar * progressBar1;
System::Windows::Forms::Label * label1;
Form1()
{
this->label2 = new System::Windows::Forms::Label();
this->progressBar1 = new System::Windows::Forms:rogressBar();
this->label1 = new System::Windows::Forms::Label();
this->label2 = new System::Windows::Forms::Label();
this->progressBar1 = new System::Windows::Forms:rogressBar();
this->label1 = new System::Windows::Forms::Label();
this->SuspendLayout();
this->label2->Font = new System:rawing::Font(S"Microsoft Sans Serif", 9.75F,
System:rawing::FontStyle::Regular, System:rawing::GraphicsUnit:oint, (System::Byte)161);
this->label2->Location = System:rawing:oint(14, 16);
this->label2->Name = S"label2";
this->label2->Size = System:rawing::Size(264, 40);
this->label2->TabIndex = 1;
this->label2->Text = S"Message 1...";
this->label2->TextAlign = System:rawing::ContentAlignment::MiddleCenter;
this->progressBar1->Location = System:rawing:oint(10, 176);
this->progressBar1->Name = S"progressBar1";
this->progressBar1->Size = System:rawing::Size(272, 23);
this->progressBar1->TabIndex = 2;
this->label1->Font = new System:rawing::Font(S"Microsoft Sans Serif", 8.25F,
System:rawing::FontStyle::Regular, System:rawing::GraphicsUnit:oint, (System::Byte)161);
this->label1->Location = System:rawing:oint(14, 80);
this->label1->Name = S"label1";
this->label1->Size = System:rawing::Size(264, 64);
this->label1->TabIndex = 3;
this->AutoScaleBaseSize = System:rawing::Size(5, 13);
this->ClientSize = System:rawing::Size(292, 271);
this->Controls->Add(this->label1);
this->Controls->Add(this->progressBar1);
this->Controls->Add(this->label2);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->Name = S"Form1";
this->Opacity = 0.9;
this->ShowInTaskbar = false;
this->Text = S"Some Application";
this->TopMost = true;
this->ResumeLayout(false);
}
};
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::Exception *pe)
{
using namespace System;
Console::WriteLine("Error: {0}", pe->Message);
return EXIT_FAILURE;
}