对话框窗口过程与普通窗口过程的区别

本文介绍了使用CreateDialog等API创建对话框窗口的方法,并详细解释了对话框窗口过程(DLGPROC)与普通窗口的区别。重点说明了消息处理流程的不同之处,强调在自定义对话框过程函数时的注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

对话框窗口是指通过CreateDialog,DialogBox 这些API创建的窗口,其中DLGPROC与普通窗口有一些区别。

HWND WINAPI CreateDialog(
  _In_opt_  HINSTANCE hInstance,
  _In_      LPCTSTR lpTemplate,
  _In_opt_  HWND hWndParent,
  _In_opt_  DLGPROC lpDialogFunc
);


MSDN对这种区别有如下解释,消息处理方面流程有所不同,我们创建对话框时传入的窗口过程,不是最终的消息处理函数,而且是供系统的DialogProc调用,切忌在自已的DialogProc中写出 return ::DefWindowProc()这样的代码




The dialog box procedure is very similar to a window procedure except for the type of return value which is TRUE/FALSE instead of LRESULT. The internal dialog box manager inside Windows IS the true window procedure for the dialog box. It calls our dialog box procedure with some messages that it received. So the general rule of thumb is that: if our dialog box procedure processes a message,it MUST return TRUE in eax and if it does not process the message, it must return FALSE in eax. Note that a dialog box procedure doesn't pass the messages it does not process to the DefWindowProc call since it's not a real window procedure.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值