C++ Builder中Application->ProcessMessages()的功能在VC中如何实现?急,谢谢!

viliky 2004-07-28 04:50:20
如题。
...全文
537 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Linux2001 2004-07-29
  • 打赏
  • 举报
回复
同意 hahu(地痞 -- 勿近)
viliky 2004-07-29
  • 打赏
  • 举报
回复
还有,GetMessage、TranslateMessage和DispatchMessage这些函数可以在文档中使用吗?
Kudeet 2004-07-29
  • 打赏
  • 举报
回复
是一个消息处理的问题
viliky 2004-07-29
  • 打赏
  • 举报
回复
再问一下,这个不涉及到多线程吧
viliky 2004-07-29
  • 打赏
  • 举报
回复
再顶
Kudeet 2004-07-28
  • 打赏
  • 举报
回复
同意楼上

MSG msg;
GetMessage(&msg,NULL,0,0);
PreTranslateMessage(&msg);
flyelf 2004-07-28
  • 打赏
  • 举报
回复
PeekMessage(...)
hahu 2004-07-28
  • 打赏
  • 举报
回复
应该是这样

while (GetMessage(&msg, NULL, 0, 0))
{

TranslateMessage(&msg);

DispatchMessage(&msg);

}
viliky 2004-07-28
  • 打赏
  • 举报
回复
C++ Builder中的说明
Interrupts the execution of an application so that it can process the event queue.

void __fastcall ProcessMessages(void);

Description

Call 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");
}

谢谢帮忙!
flyelf 2004-07-28
  • 打赏
  • 举报
回复
Application->ProcessMessages实现的是什么功能?

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧