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

viliky 2004-07-28 04:50:20
如题。
...全文
614 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实现的是什么功能?
随着通信电子技术的迅速发展,信息技术给家居行业产生了深远的影响,家居环境的智能化监控已经成为智能家居的一个重要的发展方向。人们逐渐对自己的生活提出一种更高的要求,他们需要一种智能化、可交互,并且融合现代创新科技的产品来改善他们的生活环境,使他们生活更加安全、舒适、便捷、智能。本文根据智能家居的发展背景和研究现状,并且从实用性和可行性角度出发,研究设计了一种基于STM32单片机的智能家居系统。该系统由一个多功能综合的技术系统组成,各个多功能子系统间具有协同配合能力。基于STM32单片机实现功能子系统包括:智能温度检测,智能湿度检测,智能烟雾/火灾检测智能检测,无线传输,人机交互机构,风扇调节,报警模块。 整个系统分为前端51单片机采集板和后端STM32单片机接收板。 采集板使用DHT11温湿度传感器、MQ烟雾传感器完成室内家居环境的采集。然后通过nRFL24L01将采集到的数据发送给后端。接收板使用LCD1602完成数据显示、使用蜂鸣器模块报警,使用风扇驱动模块调节室内家居环境。本文完成了智能家居控制系统前端、后端软硬件的设计,使用Altium designer绘制了电路原理图,使用Keil C完成了51单片机和STM32单片机的编程与调试。 最后,对本文设计的基于STM32的智能家居控制系统进行部署调试。试验结果表明,该系统可成功应用在智能家居环境检测调节和火灾安全防护的领域,可提高家居生活智能化水平。

16,550

社区成员

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

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

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