INT_PTR CALLBACK DialogProc(HWND hwndDlog, UINT uMsg, WPARAM wParam, LPARAM lparam) {//消息回调函数 switch (uMsg) { case WM_COMMAND: if (LOWORD(wParam) == IDOK) { float left1 = GetDlgItemFlaot(hwndDlog, IDC_LEFT1); float right1 = GetDlgItemFlaot(hwndDlog, IDC_RIGHT1); SetDlgItemFloat(hwndDlog, IDC_RESULT1, left1 + right1); }
if (LOWORD(wParam) == IDCANCEL) { EndDialog(hwndDlog, IDCANCEL); } break; } return FALUSE; }
WM_COMMAND: from the menu item or keyboard shortcut button control and so on.
Here a message is received to the page among the operations caused by the matching and parsing ,, i.e. the same message and performs a corresponding operation.
INT_PTR CALLBACK msgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: SetWindowText(hwnd, "简单的"); break; case WM_CLOSE: EndDialog(hwnd, WM_CLOSE); break; case WM_LBUTTONDOWN: { char s[256]; int x = LOWORD(lParam); int y = HIWORD(lParam); sprintf(s, "鼠标左键点击:x:%d,y:%d", x, y); SetWindowText(hwnd, s); } break; } return FALSE; }
Since this presses the left mouse button and the corresponding content is not visible WM_COMMAND WM_LBUTTONDOWN message contains belongs.
Can be understood, when an OK button is pressed, the button because there is a corresponding ID, you will find the message corresponding WM_COMMAND ID generated at the time of the response.
But when the click of a mouse or keyboard when the ID does not correspond with it, but there's incident response and this corresponds to that WM_LBUTTONDOWN.