LRESULT CALLBACK WndProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) { switch (uiMsg) { HANDLE_MSG(hwnd, WM_CREATE, OnCreate); HANDLE_MSG(hwnd, WM_SIZE, OnSize); HANDLE_MSG(hwnd, WM_DESTROY, OnDestroy); HANDLE_MSG(hwnd, WM_PAINT, OnPaint); case WM_PRINTCLIENT: OnPrintClient(hwnd, (HDC)wParam); return 0; case WM_CONTEXTMENU: if (lParam != -1 && SendMessage(hwnd, WM_NCHITTEST, 0, lParam) == HTSYSMENU) { HMENU hmenu = CreatePopupMenu(); if (hmenu) { AppendMenu(hmenu, MF_STRING, 1, TEXT("Custom menu")); TrackPopupMenu(hmenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), 0, hwnd, NULL); DestroyMenu(hmenu); } return 0; } break; } return DefWindowProc(hwnd, uiMsg, wParam, lParam); }
LRESULT CALLBACK WndProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) { switch (uiMsg) { HANDLE_MSG(hwnd, WM_CREATE, OnCreate); HANDLE_MSG(hwnd, WM_SIZE, OnSize); HANDLE_MSG(hwnd, WM_DESTROY, OnDestroy); HANDLE_MSG(hwnd, WM_PAINT, OnPaint); case WM_PRINTCLIENT: OnPrintClient(hwnd, (HDC)wParam); return 0; } return DefWindowProc(hwnd, uiMsg, wParam, lParam); }
LRESULT CALLBACK WndProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam) { switch (uiMsg) { HANDLE_MSG(hwnd, WM_CREATE, OnCreate); HANDLE_MSG(hwnd, WM_SIZE, OnSize); HANDLE_MSG(hwnd, WM_DESTROY, OnDestroy); HANDLE_MSG(hwnd, WM_PAINT, OnPaint); HANDLE_MSG(hwnd, WM_CTLCOLORLISTBOX, OnCtlColor); HANDLE_MSG(hwnd, WM_CTLCOLORSTATIC, OnCtlColor); HANDLE_MSG(hwnd, WM_NCHITTEST, OnNCHitTest); HANDLE_MSG(hwnd, WM_MEASUREITEM, MainWnd_OnMeasureItem); HANDLE_MSG(hwnd, WM_DRAWITEM, MainWnd_OnDrawItem); case WM_PRINTCLIENT: OnPrintClient(hwnd, (HDC)wParam); return 0; } return DefWindowProc(hwnd, uiMsg, wParam, lParam); }
BOOL CTutorialWindow::ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT & lResult) { switch (uMsg) { case WM_CREATE: { lResult = OnCreate(reinterpret_cast<LPCREATESTRUCT>(lParam)); return TRUE; } case WM_DESTROY: { OnDestroy(); lResult = 0; return TRUE; } case WM_CLOSE: { OnClose(); lResult = 0; return TRUE; } case WM_KEYDOWN: { OnKeyDown((TCHAR)wParam, (UINT)lParam & 0xfff, (UINT)((lParam >> 16) & 0xffff)); lResult = 0; return TRUE; } case WM_LBUTTONDOWN: { OnLButtonDown(wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); lResult = 0; return TRUE; } case WM_CONTEXTMENU: { OnContextMenu((HWND)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); lResult = 0; return TRUE; } case WM_SETFOCUS: { OnSetFocus((HWND)wParam); lResult = 0; return TRUE; } case WM_PAINT: { OnPaint((HDC)wParam); lResult = 0; return TRUE; } case WM_PRINTCLIENT: { OnPrintClient((HDC)wParam, (UINT)lParam); lResult = 0; return TRUE; } } // The framework will call DefWindowProc() for us. return FALSE; }