C++ Builder中的说明 Interrupts the execution of an application so that it can process the event queue.void __fastcall ProcessMessages(void);DescriptionCall ProcessMessages to permit the application to process events that are currently in the queue. Note: ProcessMessages does not allow the application to go idle, whereas HandleMessage does.例子: This example uses two buttons that are long enough to accommodate lengthy captions on a form. When the user clicks the button with the caption Ignore Messages, the code begins to generate a long series of random numbers. If the user tries to resize the form while the handler is running, nothing happens until the handler is finished. When the user clicks the button with the caption Process Messages, more random numbers are generated, but the application can still respond to a series of mouse events, such as resizing the form.Note: How quickly these event handlers run depends on the microprocessor of your computer. A message appears on the form informing you when the handler has finished executing.void __fastcall TForm1::FormCreate(TObject* Sender){ Button1->Caption = "Ignore Messages"; Button2->Caption = "Handle Message"; }void __fastcall TForm1::Button1Click(TObject* Sender) { int x, y; for (int i = 0; i < 64000; i++) { Randomize(); for (int j = 0; j < 64000; j++) y = random(j); x = random(i); } Canvas->TextOut(10, 10, "The Button1Click handler is finished"); }void __fastcall TForm1::Button2Click(TObject *Sender){ int x, y; for (int i = 0; i < 64000; i++) { Randomize(); for (int j = 0; j < 64000; j++) { y = random(j); Application->ProcessMessages(); } x = random(i); } Canvas->TextOut(10, 10, "The Button2Click handler is finished"); }谢谢帮忙!
Interrupts the execution of an application so that it can process the event queue.void __fastcall ProcessMessages(void);DescriptionCall ProcessMessages to permit the application to process events that are currently in the queue. Note: ProcessMessages does not allow the application to go idle, whereas HandleMessage does.例子:
This example uses two buttons that are long enough to accommodate lengthy captions on a form. When the user clicks the button with the caption Ignore Messages, the code begins to generate a long series of random numbers. If the user tries to resize the form while the handler is running, nothing happens until the handler is finished. When the user clicks the button with the caption Process Messages, more random numbers are generated, but the application can still respond to a series of mouse events, such as resizing the form.Note: How quickly these event handlers run depends on the microprocessor of your computer. A message appears on the form informing you when the handler has finished executing.void __fastcall TForm1::FormCreate(TObject* Sender){
Button1->Caption = "Ignore Messages";
Button2->Caption = "Handle Message";
}void __fastcall TForm1::Button1Click(TObject* Sender)
{
int x, y;
for (int i = 0; i < 64000; i++)
{
Randomize();
for (int j = 0; j < 64000; j++)
y = random(j);
x = random(i);
}
Canvas->TextOut(10, 10, "The Button1Click handler is finished");
}void __fastcall TForm1::Button2Click(TObject *Sender){
int x, y;
for (int i = 0; i < 64000; i++)
{
Randomize();
for (int j = 0; j < 64000; j++)
{
y = random(j);
Application->ProcessMessages();
}
x = random(i);
}
Canvas->TextOut(10, 10, "The Button2Click handler is finished");
}谢谢帮忙!
{TranslateMessage(&msg);DispatchMessage(&msg);}
GetMessage(&msg,NULL,0,0);
PreTranslateMessage(&msg);