前言

将代码拆分了一下, 如果处理更多的消息也不怕看的眼花
SDK编程就是对各种Windows消息的处理

实验工程

  1. /// @file exam_1.cpp
  2. /// @brief 查阅本地MSDN, 手工写SDK程序
  3. #include "common.h"
  4. #include "ErrorProc.h"
  5. #include "WindowProc.h"
  6. int WINAPI WinMain(HINSTANCE hInstance,
  7. HINSTANCE hPrevInstance,
  8. LPSTR lpCmdLine,
  9. int nCmdShow) {
  10. if (!fnRegisterClass(hInstance, hPrevInstance, lpCmdLine, nCmdShow)) {
  11. ShowErrMsg();
  12. goto WINMAIN_END;
  13. }
  14. if (!fnCreateWindow(hInstance, hPrevInstance, lpCmdLine, nCmdShow)) {
  15. ShowErrMsg();
  16. goto WINMAIN_END;
  17. }
  18. MsgLoop();
  19. WINMAIN_END:
  20. return 0;
  21. }
 
  1. /// @file common.h
  2. /// @brief 公用头文件
  3. #ifndef COMMON_H_2016_0128
  4. #define COMMON_H_2016_0128
  5. #define _WIN32_WINDOWS 0x500
  6. #include <windows.h>
  7. #include <tchar.h>
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #endif // #ifndef COMMON_H_2016_0128
  1. /// @file ErrorProc.h
  2. /// @brief 错误处理
  3. #ifndef ERRORPROC_H_2016_0128
  4. #define ERRORPROC_H_2016_0128
  5. const TCHAR* StringFormatV(TCHAR* szFormat, ...);
  6. void ShowMsg(const TCHAR* pcMsg);
  7. void ShowErrMsg();
  8. BOOL isQuitProg(HWND hWnd);
  9. #endif // #ifndef ERRORPROC_H_2016_0128
  1. /// @file WindowProc.h
  2. /// @brief 消息处理
  3. /// 消息处理函数命名规范
  4. /// OnX On说明是Windows消息处理函数
  5. /// X是消息 WM_X 去掉 WM_ 之后,按照将X按照匈牙利写法拼在On后面
  6. /// e.g. WM_CLOSE消息处理函数为OnClose
  7. #ifndef WINDOWPROC_H_2016_0128
  8. #define WINDOWPROC_H_2016_0128
  9. #include "common.h"
  10. BOOL fnRegisterClass(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
  11. BOOL fnCreateWindow(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
  12. void MsgLoop();
  13. HWND getMainWnd();
  14. HINSTANCE getInstance();
  15. LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  16. LONG fnDispatchMessage(CONST MSG* lpMsg);
  17. BOOL OnKeyDown(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  18. BOOL OnChar(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  19. BOOL OnSysDeadChar(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  20. BOOL OnSysChar(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  21. BOOL OnSysKeyDown(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  22. BOOL OnSysKeyUp(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  23. BOOL OnMouse(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  24. BOOL OnMouseMove(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  25. BOOL OnMouseWheel(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  26. BOOL OnMouseLButtonDown(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  27. BOOL OnMouseLButtonUp(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  28. BOOL OnMouseLButtonDblClk(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  29. BOOL OnMouseRButtonDown(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  30. BOOL OnMouseRButtonUp(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  31. BOOL OnMouseRButtonDblClk(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  32. BOOL OnMouseMButtonDown(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  33. BOOL OnMouseMButtonUp(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  34. BOOL OnMouseMButtonDblClk(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  35. BOOL OnClose(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  36. BOOL OnDestory(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  37. #endif // #ifndef WINDOWPROC_H_2016_0128
  1. /// @file common.cpp
  2. /// @brief 公用头文件对应的实现
  3. #include "common.h"
  1. /// @file ErrorProc.cpp
  2. /// @brief 错误处理实现
  3. #include "common.h"
  4. #include "ErrorProc.h"
  5. #include "WindowProc.h"
  6. BOOL isQuitProg(HWND hWnd) {
  7. BOOL bRc = FALSE;
  8. if (IDYES == MessageBox(hWnd, _T("是否退出?"), _T("提示"), MB_YESNO)) {
  9. bRc = TRUE;
  10. }
  11. return bRc; ///< true is quit prog
  12. }
  13. void ShowErrMsg() {
  14. LPVOID lpMsgBuf = NULL;
  15. FormatMessage(
  16. FORMAT_MESSAGE_ALLOCATE_BUFFER
  17. | FORMAT_MESSAGE_FROM_SYSTEM
  18. | FORMAT_MESSAGE_IGNORE_INSERTS,
  19. NULL,
  20. GetLastError(),
  21. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
  22. (LPTSTR)&lpMsgBuf,
  23. 0,
  24. NULL);
  25. MessageBox(getMainWnd(), (LPCTSTR)lpMsgBuf, _T("Error"), MB_OK | MB_ICONINFORMATION);
  26. LocalFree(lpMsgBuf);
  27. }
  28. const TCHAR* StringFormatV(TCHAR* szFormat, ...)
  29. {
  30. /// 在栈空间上拼字符串, 如果new的话, 容易引起内存碎片
  31. /// 运行的次数多了,有可能分配不出内存来
  32. static TCHAR s_cBuf[4096] = {'\0'}; ///< _vsntprintf做了处理, 最多就是打印不全
  33. int iStringLen = 0;
  34. va_list args;
  35. va_start(args, szFormat);
  36. iStringLen = _vsntprintf(s_cBuf, (sizeof(s_cBuf) / sizeof(TCHAR)) - 1, szFormat, args);
  37. va_end(args);
  38. return s_cBuf;
  39. }
  40. void ShowMsg(const TCHAR* pcMsg) {
  41. if (NULL != pcMsg) {
  42. OutputDebugString(pcMsg);
  43. }
  44. }
  1. /// @file WindowProc.cpp
  2. /// @brief Windows消息处理的实现
  3. #include "WindowProc.h"
  4. #include "ErrorProc.h"
  5. static HWND g_hWnd = NULL;
  6. static HINSTANCE g_hInstance = NULL;
  7. HWND getMainWnd() {
  8. return g_hWnd;
  9. }
  10. HINSTANCE getInstance() {
  11. return g_hInstance;
  12. }
  13. BOOL fnRegisterClass(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  14. /// 设计,注册窗口类
  15. BOOL bRc = TRUE;
  16. ATOM _atom;
  17. WNDCLASS WndClass = {0};
  18. // 拥有了经典样式 CS_DBLCLKS, 才会响应双击操作
  19. WndClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
  20. WndClass.lpfnWndProc = &WindowProc;
  21. WndClass.cbClsExtra = 0;
  22. WndClass.cbWndExtra = 0;
  23. WndClass.hInstance = hInstance;
  24. WndClass.hIcon = NULL;
  25. WndClass.hCursor = NULL /*LoadCursor(NULL, IDC_ARROW)*/;
  26. WndClass.hbrBackground = (HBRUSH)COLOR_WINDOW;
  27. WndClass.lpszMenuName = NULL;
  28. WndClass.lpszClassName = _T("test class");///< 不能为空
  29. _atom = RegisterClass(&WndClass);
  30. if (0 == _atom) {
  31. bRc = FALSE;
  32. }
  33. g_hInstance = hInstance;
  34. return bRc;
  35. }
  36. BOOL fnCreateWindow(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  37. /// 创建, 显示窗口
  38. BOOL bRc = TRUE;
  39. g_hWnd = CreateWindow(
  40. _T("test class"),  // pointer to registered class name
  41. _T("test class window"), // pointer to window name
  42. WS_OVERLAPPEDWINDOW,        // window style
  43. 100,                // horizontal position of window
  44. 100,                // vertical position of window
  45. 800,           // window width
  46. 600,          // window height
  47. NULL,      // handle to parent or owner window
  48. NULL,          // handle to menu or child-window identifier
  49. hInstance,     // handle to application instance
  50. NULL        // pointer to window-creation data
  51. );
  52. if (NULL == g_hWnd) {
  53. bRc = FALSE;
  54. goto FNCREATEWINDOW_END;
  55. }
  56. ShowMsg(StringFormatV(_T("g_hWnd = 0x%X\n"), g_hWnd));
  57. ShowWindow(g_hWnd, SW_SHOWNORMAL);
  58. UpdateWindow(g_hWnd);
  59. FNCREATEWINDOW_END:
  60. return bRc;
  61. }
  62. void MsgLoop() {
  63. /// 消息循环
  64. MSG msg;
  65. // GetMessage参数2必须是NULL, 如果是g_hWnd, 会在WM_NCDESTROY后,
  66. // msg子项内容都全变成0, 变成一个死循环
  67. // 如果第2个参数为NULL, 会接收本进程所有窗口(线程)的消息
  68. ShowMsg(_T(">> MsgLoop()\n"));
  69. while (GetMessage(
  70. &msg,         // address of structure with message
  71. NULL,     // handle of window
  72. 0,  // first message
  73. 0   // last message
  74. )) {
  75. TranslateMessage(&msg); ///< 键盘消息到字符消息(多投递一个WM_CHAR消息)
  76. fnDispatchMessage(&msg); ///< DispatchMessage不是必须的,我们也可以自己实现
  77. }
  78. ShowMsg(_T("<< MsgLoop()\n"));
  79. }
  80. LONG fnDispatchMessage(CONST MSG* lpMsg) {
  81. long lRc = 0;
  82. int iLen = 0;
  83. TCHAR cBuf[MAXBYTE] = {_T('\0')};
  84. WNDCLASS WndClass = {0};
  85. if (NULL == lpMsg)
  86. goto FNDISPATCHMESSAGE_END;
  87. iLen = GetClassName(lpMsg->hwnd, cBuf, sizeof(cBuf)/sizeof(TCHAR));
  88. if (iLen <= 0)
  89. goto FNDISPATCHMESSAGE_END;
  90. if (!GetClassInfo(getInstance(), cBuf, &WndClass))
  91. goto FNDISPATCHMESSAGE_END;
  92. if (NULL == WndClass.lpfnWndProc)
  93. goto FNDISPATCHMESSAGE_END;
  94. lRc = WndClass.lpfnWndProc(lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam);
  95. FNDISPATCHMESSAGE_END:
  96. return lRc;
  97. }
  98. /**
  99. WM_XXX
  100. 键盘,鼠标,绘制消息
  101. WM_COMMAND
  102. 菜单,快捷键消息
  103. 快捷键消息和键盘消息不同。
  104. 键盘消息是一个一个的按键
  105. 快捷键消息是组合键.
  106. WM_NOTIFY
  107. 子窗口的消息
  108. */
  109. LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  110. BOOL bCallDefWindowProc = TRUE;
  111. LRESULT lRc = 0;
  112. ShowMsg(StringFormatV(_T("uMsg = 0x%X\n"), uMsg));
  113. /// 编码规范, 必须单独封装处理消息的函数OnMsg,
  114. /// 不允许在WindowProc中写具体的消息处理实现
  115. switch (uMsg) {
  116. case WM_KEYDOWN:
  117. bCallDefWindowProc = OnKeyDown(lRc, hwnd, uMsg, wParam, lParam);
  118. break;
  119. case WM_CHAR:
  120. bCallDefWindowProc = OnChar(lRc, hwnd, uMsg, wParam, lParam);
  121. break;
  122. case WM_SYSDEADCHAR:
  123. bCallDefWindowProc = OnSysDeadChar(lRc, hwnd, uMsg, wParam, lParam);
  124. break;
  125. case WM_SYSCHAR:
  126. bCallDefWindowProc = OnSysChar(lRc, hwnd, uMsg, wParam, lParam);
  127. break;
  128. case WM_SYSKEYDOWN:
  129. bCallDefWindowProc = OnSysKeyDown(lRc, hwnd, uMsg, wParam, lParam);
  130. break;
  131. case WM_SYSKEYUP:
  132. bCallDefWindowProc = OnSysKeyUp(lRc, hwnd, uMsg, wParam, lParam);
  133. break;
  134. case WM_MOUSEMOVE:
  135. case WM_MOUSEWHEEL:
  136. case WM_LBUTTONDOWN:
  137. case WM_LBUTTONUP:
  138. case WM_LBUTTONDBLCLK:
  139. case WM_RBUTTONDOWN:
  140. case WM_RBUTTONUP:
  141. case WM_RBUTTONDBLCLK:
  142. case WM_MBUTTONDOWN:
  143. case WM_MBUTTONUP:
  144. case WM_MBUTTONDBLCLK:
  145. bCallDefWindowProc = OnMouse(lRc, hwnd, uMsg, wParam, lParam);
  146. break;
  147. case WM_CLOSE:
  148. bCallDefWindowProc = OnClose(lRc, hwnd, uMsg, wParam, lParam);
  149. break;
  150. case WM_DESTROY:
  151. bCallDefWindowProc = OnDestory(lRc, hwnd, uMsg, wParam, lParam);
  152. break;
  153. default:
  154. break;
  155. }
  156. /// The DefWindowProc function calls the default window procedure
  157. /// to provide default processing for any window messages
  158. /// that an application does not process.
  159. return bCallDefWindowProc ? DefWindowProc(hwnd, uMsg, wParam, lParam) : lRc;
  160. }
  161. BOOL OnKeyDown(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  162. /// 如果不调用 TranslateMessage, 可以自己取按键值
  163. /// 如果调用了 TranslateMessage, 在OnChar中直接取键值
  164. ShowMsg(_T("OnKeyDown\n"));
  165. int nVirtKey = (int) wParam;    // virtual-key code
  166. ULONG ulKeyData = lParam;          // key data
  167. BYTE ucKeyState[256] = {0};
  168. WORD wChar = 0;
  169. int iRc = 0;
  170. /**
  171. lKeyData
  172. Value of lParam. Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table. Value Description
  173. 0–15 Specifies the repeat count for the current message. The value is the number of times the keystroke is auto-repeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.
  174. 16–23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM).
  175. 24 Specifies whether the key is an extended key, such as the right-hand alt and ctrl keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
  176. 25–28 Reserved; do not use.
  177. 29 Specifies the context code. The value is always 0 for a WM_KEYDOWN message.
  178. 30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up.
  179. 31 Specifies the transition state. The value is always 0 for a WM_KEYDOWN message.
  180. */
  181. if (!GetKeyboardState(&ucKeyState[0])) {
  182. goto ONKEYDOWN_END;
  183. }
  184. if (ToAscii(nVirtKey, (ulKeyData >> 16) & 0xff, ucKeyState, &wChar, 0) <= 0) {
  185. goto ONKEYDOWN_END;
  186. }
  187. ShowMsg(StringFormatV(_T("%c "), (TCHAR)wChar));
  188. ONKEYDOWN_END:
  189. lRc = 0;
  190. return TRUE;
  191. }
  192. BOOL OnChar(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  193. ShowMsg(StringFormatV(_T("%c "), (TCHAR)wParam));
  194. lRc = 0;
  195. return TRUE;
  196. }
  197. BOOL OnSysDeadChar(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  198. lRc = 0;
  199. return TRUE;
  200. }
  201. BOOL OnSysChar(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  202. lRc = 0;
  203. return TRUE;
  204. }
  205. BOOL OnSysKeyDown(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  206. /// F10 press down
  207. lRc = 0;
  208. return TRUE;
  209. }
  210. BOOL OnSysKeyUp(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  211. /// F10 press up
  212. lRc = 0;
  213. return TRUE;
  214. }
  215. BOOL OnMouse(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  216. BOOL bRc = FALSE;
  217. //     POINTS pt;
  218. //     UINT uMK = 0; // key flags
  219. //     WORD xPos = 0; // horizontal position of cursor
  220. //     WORD yPos = 0; // vertical position of cursor
  221. if ((uMsg < WM_MOUSEFIRST) || (uMsg > WM_MOUSELAST))
  222. goto ONMOUSE_END;
  223. /**
  224. * Key State Masks for Mouse Messages
  225. #define MK_LBUTTON          0x0001
  226. #define MK_RBUTTON          0x0002
  227. #define MK_SHIFT            0x0004
  228. #define MK_CONTROL          0x0008
  229. #define MK_MBUTTON          0x0010
  230. */
  231. //     uMK = wParam;
  232. //     xPos = LOWORD(lParam);
  233. //     yPos = HIWORD(lParam);
  234. //     pt = MAKEPOINTS(lParam);
  235. switch (uMsg) {
  236. // 移动
  237. case WM_MOUSEMOVE:
  238. bRc = OnMouseMove(lRc, hwnd, uMsg, wParam, lParam);
  239. break;
  240. // 滑过
  241. case WM_MOUSEWHEEL:
  242. bRc = OnMouseWheel(lRc, hwnd, uMsg, wParam, lParam);
  243. break;
  244. // 左键
  245. case WM_LBUTTONDOWN:
  246. bRc = OnMouseLButtonDown(lRc, hwnd, uMsg, wParam, lParam);
  247. break;
  248. case WM_LBUTTONUP:
  249. bRc = OnMouseLButtonUp(lRc, hwnd, uMsg, wParam, lParam);
  250. break;
  251. case WM_LBUTTONDBLCLK:
  252. bRc = OnMouseLButtonDblClk(lRc, hwnd, uMsg, wParam, lParam);
  253. break;
  254. // 右键
  255. case WM_RBUTTONDOWN:
  256. bRc = OnMouseRButtonDown(lRc, hwnd, uMsg, wParam, lParam);
  257. break;
  258. case WM_RBUTTONUP:
  259. bRc = OnMouseRButtonUp(lRc, hwnd, uMsg, wParam, lParam);
  260. break;
  261. case WM_RBUTTONDBLCLK:
  262. bRc = OnMouseRButtonDblClk(lRc, hwnd, uMsg, wParam, lParam);
  263. break;
  264. // 中键
  265. case WM_MBUTTONDOWN:
  266. bRc = OnMouseMButtonDown(lRc, hwnd, uMsg, wParam, lParam);
  267. break;
  268. case WM_MBUTTONUP:
  269. bRc = OnMouseMButtonUp(lRc, hwnd, uMsg, wParam, lParam);
  270. break;
  271. case WM_MBUTTONDBLCLK:
  272. bRc = OnMouseMButtonDblClk(lRc, hwnd, uMsg, wParam, lParam);
  273. break;
  274. default:
  275. break;
  276. }
  277. ONMOUSE_END:
  278. lRc = 0;
  279. return bRc; ///< bCallDefWindowProc
  280. }
  281. BOOL OnMouseMove(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  282. lRc = 0;
  283. return TRUE;
  284. }
  285. BOOL OnMouseWheel(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  286. lRc = 0;
  287. return TRUE;
  288. }
  289. BOOL OnMouseLButtonDown(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  290. ShowMsg(StringFormatV(_T("OnMouseLButtonDown, hwnd = 0x%X\n"), hwnd));
  291. // MessageBox(hwnd, _T("OnMouseLButtonDown"), _T("SDK Frame"), MB_OK);
  292. lRc = 0;
  293. return TRUE;
  294. }
  295. BOOL OnMouseLButtonUp(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  296. ShowMsg(StringFormatV(_T("OnMouseLButtonUp, hwnd = 0x%X\n"), hwnd));
  297. lRc = 0;
  298. return TRUE;
  299. }
  300. BOOL OnMouseLButtonDblClk(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  301. ShowMsg(_T("OnMouseLButtonDblClk\n"));
  302. lRc = 0;
  303. return TRUE;
  304. }
  305. BOOL OnMouseRButtonDown(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  306. lRc = 0;
  307. return TRUE;
  308. }
  309. BOOL OnMouseRButtonUp(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  310. lRc = 0;
  311. return TRUE;
  312. }
  313. BOOL OnMouseRButtonDblClk(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  314. lRc = 0;
  315. return TRUE;
  316. }
  317. BOOL OnMouseMButtonDown(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  318. lRc = 0;
  319. return TRUE;
  320. }
  321. BOOL OnMouseMButtonUp(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  322. lRc = 0;
  323. return TRUE;
  324. }
  325. BOOL OnMouseMButtonDblClk(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  326. lRc = 0;
  327. return TRUE;
  328. }
  329. BOOL OnClose(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  330. lRc = 0;
  331. return isQuitProg(hwnd); ///< bCallDefWindowProc
  332. }
  333. BOOL OnDestory(OUT LRESULT& lRc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  334. lRc = 0;
  335. // WM_QUIT使GetMessage为FALSE, 跳出消息循环的处理
  336. // PostMessage(hwnd, WM_QUIT, 0, 0); ///< ok
  337. PostQuitMessage(0); ///< 也会发送WM_QUIT消息
  338. return TRUE; ///< bCallDefWindowProc
  339. }

http://blog.csdn.net/lostspeed/article/details/50606215

http://blog.csdn.net/lostspeed/article/details/50614423

最新文章

  1. Websocket通讯简析
  2. exp/imp 参数说明,中英对照
  3. Android 触摸手势基础 官方文档概览
  4. C#高级编程笔记 Day 1, 2016年8月 30日 名词定义
  5. Ibatis.Net 数据库操作(四)
  6. 7、C#基础整理(类)
  7. [MongoDB] Insert, find -- 1
  8. poj 1469 COURSES(匈牙利算法模板)
  9. 使用HttpWebRequest进行请求时发生错误:基础连接已关闭,发送时发生错误处理
  10. Software Version --hdu1976
  11. usb调试
  12. Number,parseInt,parseFloat函数
  13. oracle查看表空间下数据文件
  14. Python爬虫-尝试使用人工和OCR处理验证码模拟登入
  15. 遍历一个List的几种方法
  16. Simditor 富文本编辑器多选图片上传、视频连接插入
  17. EOS智能合约开发(一):EOS环境搭建和启动节点
  18. newcoder Tachibana Kanade Loves Probability(小数点后第k位)题解
  19. 【BJOI2019】排兵布阵 DP
  20. JavaSE学习总结(六)——接口、抽象类、内部类

热门文章

  1. linux进程间通信之信号
  2. windows上运行npm Error: ENOENT, stat &#39;C:\Users\
  3. [译]MDX 介绍
  4. JavaSE学习总结第15天_集合框架1
  5. struts2的坑以及tomcat的一些常识
  6. Python之路Day17
  7. detain ssh server 设置(也许必须是root来安装?)
  8. urllib2使用2
  9. JavaEE Tutorials (4) - 企业bean入门
  10. cocos2D(二)---- cocos2D文档的使用