windowsx.h中有以下宏定义:
#define HANDLE_MSG(hwnd, message, fn) \
case (message): return HANDLE_##message((hwnd), (wParam), (lParam), (fn))
#define HANDLE_WM_CREATE(hwnd, wParam, lParam, fn) \
((fn)((hwnd), (LPCREATESTRUCT)(lParam)) ? 0L : (LRESULT)-1L)
当我们写下下面的代码时:
HANDLE_MSG(hWnd, WM_CREATE, pWindow->OnCreate);
根据第一条宏定义会转化为:
case (WM_CREATE) : return HANDLE_WM_CREATE(((hwnd), (wParam), (lParam), (pWindow->OnCreate))
接下来使用第二条宏定义来替换,就成这样的了:
case (WM_CREATE) : return pWindow->OnCreate((hwnd), (LPCREATESTRUCT)(lParam)) ? 0L : (LRESULT)-1L)
忘了提醒了^_^,##的作用是将两个字符串连接起来