- if (!wnd && wxWndHook)
- {
- wxAssociateWinWithHandle(hWnd, wxWndHook);
- wnd = wxWndHook;
- wxWndHook = NULL;
- wnd->m_hWnd = (WXHWND) hWnd;
- }
-
- // Stop right here if we don't have a valid handle
- // in our wxWnd object.
- if (wnd && !wnd->m_hWnd) {
- // wxDebugMsg("Warning: could not find a valid handle, wx_win.cc/wxWndProc.\n");
- wnd->m_hWnd = (WXHWND) hWnd;
- long res = wnd->MSWDefWindowProc(message, wParam, lParam );
- wnd->m_hWnd = 0;
- return res;
- }
-
- if (wnd) {
- wnd->m_lastMsg = message;
- wnd->m_lastWParam = wParam;
- wnd->m_lastLParam = lParam;
- }
- if (wnd)
- return wnd->MSWWindowProc(message, wParam, lParam);
- else
- return DefWindowProc( hWnd, message, wParam, lParam );
-}
-
-// Should probably have a test for 'genuine' NT
-#if defined(__WIN32__)
- #define DIMENSION_TYPE short
-#else
- #define DIMENSION_TYPE int
-#endif
-
-// Main Windows 3 window proc
-long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
-{
- wxASSERT( m_lastMsg == message &&
- m_lastWParam == wParam && m_lastLParam == lParam );
-
-#ifdef __WXDEBUG__
- wxLogTrace(wxTraceMessages, "Processing %s(%lx, %lx)",
- wxGetMessageName(message), wParam, lParam);
-#endif // __WXDEBUG__
-
- HWND hWnd = (HWND)m_hWnd;
-
- switch (message)
- {
- case WM_ACTIVATE:
- {
-#ifdef __WIN32__
- WORD state = LOWORD(wParam);
- WORD minimized = HIWORD(wParam);
- HWND hwnd = (HWND)lParam;
-#else
- WORD state = (WORD)wParam;
- WORD minimized = LOWORD(lParam);
- HWND hwnd = (HWND)HIWORD(lParam);
-#endif
- MSWOnActivate(state, (minimized != 0), (WXHWND) hwnd);
- return 0;
- break;
- }
- case WM_SETFOCUS:
- {
- HWND hwnd = (HWND)wParam;
- // return OnSetFocus(hwnd);
-
- if (MSWOnSetFocus((WXHWND) hwnd))
- return 0;
- else return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
- case WM_KILLFOCUS:
- {
- HWND hwnd = (HWND)lParam;
- // return OnKillFocus(hwnd);
- if (MSWOnKillFocus((WXHWND) hwnd))
- return 0;
- else
- return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
- case WM_CREATE:
- {
- MSWOnCreate((WXLPCREATESTRUCT) (LPCREATESTRUCT)lParam);
- return 0;
- break;
- }
- case WM_SHOWWINDOW:
- {
- MSWOnShow((wParam != 0), (int) lParam);
- break;
- }
- case WM_PAINT:
- {
- if (MSWOnPaint())
- return 0;
- else return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
- case WM_QUERYDRAGICON:
- {
- HICON hIcon = (HICON)MSWOnQueryDragIcon();
- if ( hIcon )
- return (long)hIcon;
- else
- return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
-
- case WM_SIZE:
- {
- int width = LOWORD(lParam);
- int height = HIWORD(lParam);
- MSWOnSize(width, height, wParam);
- break;
- }
-
- case WM_MOVE:
- {
- wxMoveEvent event(wxPoint(LOWORD(lParam), HIWORD(lParam)),
- m_windowId);
- event.SetEventObject(this);
- if ( !GetEventHandler()->ProcessEvent(event) )
- Default();
- }
- break;
-
- case WM_WINDOWPOSCHANGING:
- {
- MSWOnWindowPosChanging((void *)lParam);
- break;
- }
-
- case WM_RBUTTONDOWN:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnRButtonDown(x, y, wParam);
- break;
- }
- case WM_RBUTTONUP:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnRButtonUp(x, y, wParam);
- break;
- }
- case WM_RBUTTONDBLCLK:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnRButtonDClick(x, y, wParam);
- break;
- }
- case WM_MBUTTONDOWN:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnMButtonDown(x, y, wParam);
- break;
- }
- case WM_MBUTTONUP:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnMButtonUp(x, y, wParam);
- break;
- }
- case WM_MBUTTONDBLCLK:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnMButtonDClick(x, y, wParam);
- break;
- }
- case WM_LBUTTONDOWN:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnLButtonDown(x, y, wParam);
- break;
- }
- case WM_LBUTTONUP:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnLButtonUp(x, y, wParam);
- break;
- }
- case WM_LBUTTONDBLCLK:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnLButtonDClick(x, y, wParam);
- break;
- }
- case WM_MOUSEMOVE:
- {
- int x = (DIMENSION_TYPE) LOWORD(lParam);
- int y = (DIMENSION_TYPE) HIWORD(lParam);
- MSWOnMouseMove(x, y, wParam);
- break;
- }
- case MM_JOY1BUTTONDOWN:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyDown(wxJOYSTICK1, x, y, wParam);
- break;
- }
- case MM_JOY2BUTTONDOWN:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyDown(wxJOYSTICK2, x, y, wParam);
- break;
- }
- case MM_JOY1BUTTONUP:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyUp(wxJOYSTICK1, x, y, wParam);
- break;
- }
- case MM_JOY2BUTTONUP:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyUp(wxJOYSTICK2, x, y, wParam);
- break;
- }
- case MM_JOY1MOVE:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyMove(wxJOYSTICK1, x, y, wParam);
- break;
- }
- case MM_JOY2MOVE:
- {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
- MSWOnJoyMove(wxJOYSTICK2, x, y, wParam);
- break;
- }
- case MM_JOY1ZMOVE:
- {
- int z = LOWORD(lParam);
- MSWOnJoyZMove(wxJOYSTICK1, z, wParam);
- break;
- }
- case MM_JOY2ZMOVE:
- {
- int z = LOWORD(lParam);
- MSWOnJoyZMove(wxJOYSTICK2, z, wParam);
- break;
- }
- case WM_DESTROY:
- {
- if (MSWOnDestroy())
- return 0;
- else return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
- case WM_SYSCOMMAND:
- {
- return MSWOnSysCommand(wParam, lParam);
- break;
- }
- case WM_COMMAND:
- {
-#ifdef __WIN32__
- WORD id = LOWORD(wParam);
- HWND hwnd = (HWND)lParam;
- WORD cmd = HIWORD(wParam);
-#else
- WORD id = (WORD)wParam;
- HWND hwnd = (HWND)LOWORD(lParam) ;
- WORD cmd = HIWORD(lParam);
-#endif
- if (!MSWOnCommand(id, cmd, (WXHWND) hwnd))
- return MSWDefWindowProc(message, wParam, lParam );
- break;
- }
-#if defined(__WIN95__)
- case WM_NOTIFY:
- {
- // for some messages (TVN_ITEMEXPANDING for example), the return
- // value of WM_NOTIFY handler is important, so don't just return 0
- // if we processed the message
- return MSWOnNotify(wParam, lParam);
- }
-#endif
- case WM_MENUSELECT:
- {
-#ifdef __WIN32__
- WORD flags = HIWORD(wParam);
- HMENU sysmenu = (HMENU)lParam;
-#else
- WORD flags = LOWORD(lParam);
- HMENU sysmenu = (HMENU)HIWORD(lParam);
-#endif
- MSWOnMenuHighlight((WORD)wParam, flags, (WXHMENU) sysmenu);
- break;
- }
- case WM_INITMENUPOPUP:
- {
- MSWOnInitMenuPopup((WXHMENU) (HMENU)wParam, (int)LOWORD(lParam), (HIWORD(lParam) != 0));
- break;
- }
- case WM_DRAWITEM:
- {
- return MSWOnDrawItem((int)wParam, (WXDRAWITEMSTRUCT *)lParam);
- break;
- }
- case WM_MEASUREITEM:
- {
- return MSWOnMeasureItem((int)wParam, (WXMEASUREITEMSTRUCT *)lParam);
- break;
- }
-
- case WM_KEYDOWN:
- {
- MSWOnKeyDown((WORD) wParam, lParam);
- // we consider these message "not interesting"
- if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
- return Default();
-
- // Avoid duplicate messages to OnChar
- if ( (wParam != VK_ESCAPE) && (wParam != VK_SPACE) &&
- (wParam != VK_RETURN) && (wParam != VK_BACK) &&
- (wParam != VK_TAB) )
- {
- MSWOnChar((WORD)wParam, lParam);
- if ( ::GetKeyState(VK_CONTROL) & 0x100 )
- return Default();
- }
- else if ( ::GetKeyState(VK_CONTROL) & 0x100 )
- MSWOnChar((WORD)wParam, lParam);
- else
- return Default();
- break;
- }
-
- case WM_KEYUP: