关于HANDLE_##MESSAGE , chHANDLE_DLGMSG宏的理解!!!!

来源:互联网 发布:qq飞车抽奖软件 编辑:程序博客网 时间:2024/05/04 14:24

 今天看了windows核心编程。里面用到了HANDLE_##MESSAGE这个宏,特意查看了下,原来如下:

 

#define chHANDLE_DLGMSG(hWnd, message, fn)                 /
   case (message): return (SetDlgMsgResult(hWnd, uMsg,     /
      HANDLE_##message((hWnd), (wParam), (lParam), (fn))))

 

 对于HANDLE_##message  中##,实际上编译器对这个符号的处理喊简单,就是讲两个字符串进行连接。

比如当messge = WM_INITDIALOG的时候,他就变成了如下形式:

#define HANDLE_WM_INITDIALOG(hwnd, wParam, lParam, fn) /
    (LRESULT)(DWORD)(UINT)(BOOL)(fn)((hwnd), (HWND)(wParam), lParam)

而想上面这些宏都是在windowsx.h中已经定义好了的!!!!

 而

 

SetDlgMsgResult(   HWND hwnd,   int msg,   LONG result );

Parameters

hwnd
Handle to the dialog box.
msg
Specifies the zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus four.
result
Specifies the replacement value.

这个函数的作用就是讲对话框上的消息交给哪个消息处理函数来处理!

无非就是调用自己定义的消息处理函数!!

很容易理解!

 

 所在目录:(自己机器上)

f:/vs2005/vc/platformsdk/include/windowsx.h