LRESULT CALLBACK EXPORT AWClientWndProc ( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { LRESULT lRet; BOOL fHandled; Window* pWnd = (Window*)GetWindowLong(hwnd, I_GWL_WINDOW); Shapes* pShapes = (Shapes*)GetWindowLong(hwnd, I_GWL_SHAPES); switch (uMsg) { case WM_CREATE: pWnd = (Window*)(((CREATESTRUCT*)lParam)->lpCreateParams); pShapes = (pWnd->GetLayout())->Shapes(); SetWindowLong(hwnd, I_GWL_WINDOW, (long)pWnd); SetWindowLong(hwnd, I_GWL_SHAPES, (long)pShapes); fHandled = TRUE; lRet = 0L; break; // the following messages are processed by the Shapes class case WM_MOUSEMOVE: pShapes->MouseMove(pWnd, hwnd, (int)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); fHandled = TRUE; lRet = 0L; break; case WM_LBUTTONDOWN: pShapes->MouseLButtonDown(pWnd, hwnd, (int)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); fHandled = TRUE; lRet = 0L; break; case WM_LBUTTONDBLCLK: pShapes->MouseLButtonDblClk(pWnd, hwnd, (int)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); fHandled = TRUE; lRet = 0L; break; case WM_LBUTTONUP: pShapes->MouseLButtonUp(pWnd, hwnd, (int)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); fHandled = TRUE; lRet = 0L; break; case WM_RBUTTONDOWN: pShapes->MouseRButtonDown(pWnd, hwnd, (int)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); fHandled = TRUE; lRet = 0L; break; case WM_KEYDOWN: pShapes->KeyDown(pWnd, hwnd, (int)wParam, lParam); fHandled = TRUE; lRet = 0L; break; case WM_KEYUP: pShapes->KeyUp(pWnd, hwnd, (int)wParam, lParam); fHandled = TRUE; lRet = 0L; break; // the following messages are handled by the Window class case WM_ERASEBKGND: pWnd->EraseBackground((HDC)wParam); fHandled = TRUE; lRet = 0L; break; case WM_PAINT: (pWnd->Items())->Paint(); fHandled = TRUE; lRet = 0L; break; case WM_HSCROLL: HANDLE_WM_HSCROLL(hwnd, wParam, lParam, (pWnd->Items())->HScroll); fHandled = TRUE; lRet = 0L; break; case WM_VSCROLL: HANDLE_WM_VSCROLL(hwnd, wParam, lParam, (pWnd->Items())->VScroll); fHandled = TRUE; lRet = 0L; break; case WM_DELETEITEM: case WM_COMPAREITEM: case WM_MEASUREITEM: case WM_DRAWITEM: #if defined(__FLAT__) case WM_CTLCOLORBTN: case WM_CTLCOLORDLG: case WM_CTLCOLOREDIT: case WM_CTLCOLORLISTBOX: case WM_CTLCOLORSCROLLBAR: case WM_CTLCOLORSTATIC: #else case WM_CTLCOLOR: #endif lRet = (pWnd->Items())->ParentNotified(hwnd, uMsg, wParam, lParam); fHandled = TRUE; break; default: fHandled = FALSE; break; } return fHandled ? lRet : DefWindowProc(hwnd, uMsg, wParam, lParam); }
LRESULT CALLBACK EXPORT AWFrameWndProc ( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { LRESULT lRet; BOOL fHandled; Window* pWnd; switch (uMsg) { case WM_CREATE: pWnd = (Window*)(((CREATESTRUCT*)lParam)->lpCreateParams); SetWindowLong(hwnd, I_GWL_WINDOW, (long)pWnd); pWnd->FrameWndCreated(hwnd); fHandled = TRUE; lRet = 0L; break; case WM_SIZE: pWnd = (Window*)GetWindowLong(hwnd, I_GWL_WINDOW); I_ASSERT(pWnd); HANDLE_WM_SIZE(hwnd, wParam, lParam, pWnd->Size); fHandled = FALSE; break; case WM_MOVE: pWnd = (Window*)GetWindowLong(hwnd, I_GWL_WINDOW); I_ASSERT(pWnd); HANDLE_WM_MOVE(hwnd, wParam, lParam, pWnd->Move); fHandled = FALSE; break; case WM_GETMINMAXINFO: pWnd = (Window*)GetWindowLong(hwnd, I_GWL_WINDOW); if(!pWnd) // this comes before WM_CREATE ... thanks MicroSUCKS pWnd = g_pWnd; I_ASSERT(pWnd); pWnd->GetMinMaxInfo((MINMAXINFO*)lParam); fHandled = TRUE; lRet = 0L; break; case WM_KEYDOWN: pWnd = (Window*)GetWindowLong(hwnd, I_GWL_WINDOW); I_ASSERT(pWnd); pWnd->GetLayout()->Shapes()->KeyDown(pWnd, pWnd->ClientWnd(), (int)wParam, lParam); fHandled = TRUE; lRet = 0L; break; case WM_KEYUP: pWnd = (Window*)GetWindowLong(hwnd, I_GWL_WINDOW); I_ASSERT(pWnd); pWnd->GetLayout()->Shapes()->KeyUp(pWnd, pWnd->ClientWnd(), (int)wParam, lParam); fHandled = TRUE; lRet = 0L; break; case WM_INITMENUPOPUP: I_ASSERT(GetSystemMenu(hwnd, FALSE) == (HMENU)wParam); EnableMenuItem((HMENU)wParam, 3, MF_BYPOSITION | MF_GRAYED); EnableMenuItem((HMENU)wParam, 4, MF_BYPOSITION | MF_GRAYED); fHandled = TRUE; lRet = 0L; break; case WM_SYSCOMMAND: switch(wParam & 0xFFF0) { case SC_MAXIMIZE: case SC_MINIMIZE: fHandled = TRUE; lRet = 0L; break; default: fHandled = FALSE; break; } break; default: fHandled = FALSE; break; } return fHandled ? lRet : DefWindowProc(hwnd, uMsg, wParam, lParam); }