Windows SDK笔记(四):模式对话框

来源:互联网 发布:udp 123端口 编辑:程序博客网 时间:2024/05/22 07:19
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

 

一、概述

对话框是一种特殊的窗口,它依据对话框模板资源而建立。
它与一般的窗口有些不同,很多过程由系统完成了,虽然用户还是要提供一个消息处理函数,但在此消息处理函数中,不需要将不关心的消息交由缺省消息处理函数。
实际上,调用缺省处理的过程又系统完成。

二、对话框消息处理函数

对话框也需要用户提供一个消息处理函数,但这个处理函数没有普通窗口的消息处理函数"权利大"。
对话框是一种系统定义的“窗口类”,它已经定义好了对应的消息处理函数。客户所作的消息处理函数,并不是直接与窗口连接,而是对对话框消息处理函数的一种补充,或者说“嵌入”。
因此,对话框处理函数不需要调用“缺省消息处理函数”。
当有消息被处理时,返回TRUE,没有消息需要处理时,返回FALSE,此时退出用户消息处理函数后,系统会去调缺省消息处理函数。

//对话框消息处理函数//返回值类型为BOOL,与普通窗口处理函数不同。BOOL CALLBACK AboutDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){     switch (message)     {     case WM_INITDIALOG :          return TRUE ;<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击