LRESULT CALLBACK Window::WindowWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) { Window* pThis = get_window(hwnd); if (!pThis) pThis = create_controller(hwnd); if (pThis) { switch(nmsg) { case WM_COMMAND: return pThis->Command(LOWORD(wparam), HIWORD(wparam)); case WM_NOTIFY: return pThis->Notify(wparam, (NMHDR*)lparam); case WM_NOTIFYFORMAT: return NFR_CURRENT; case WM_CREATE: return pThis->Init((LPCREATESTRUCT)lparam); case WM_NCDESTROY: delete pThis; return 0; default: return pThis->WndProc(nmsg, wparam, lparam); } } else return DefWindowProc(hwnd, nmsg, wparam, lparam); }
INT_PTR CALLBACK Window::DialogProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam) { Window* pThis = get_window(hwnd); if (pThis) { switch(nmsg) { case WM_COMMAND: SetWindowLong(hwnd, DWL_MSGRESULT, (LPARAM)pThis->Command(LOWORD(wparam), HIWORD(wparam))); return TRUE; // message has been processed case WM_NOTIFY: pThis->Notify(wparam, (NMHDR*)lparam); return TRUE; // message has been processed case WM_NOTIFYFORMAT: SetWindowLong(hwnd, DWLP_MSGRESULT, NFR_CURRENT); // set return value NFR_CURRENT return TRUE; // message has been processed case WM_NCDESTROY: delete pThis; return TRUE; // message has been processed default: return pThis->WndProc(nmsg, wparam, lparam); } } else if (nmsg == WM_INITDIALOG) { pThis = create_controller(hwnd); if (pThis) return pThis->Init(NULL); return TRUE; } return FALSE; // message has not been processed }