+ case WM_SIZE:
+ switch ( wParam )
+ {
+ case SIZE_MAXHIDE:
+ case SIZE_MAXSHOW:
+ // we're not interested in these messages at all
+ break;
+
+ case SIZE_MINIMIZED:
+ // we shouldn't send sizev events for these messages as the
+ // client size may be negative which breaks existing code
+ //
+ // OTOH we might send another (wxMinimizedEvent?) one or
+ // add an additional parameter to wxSizeEvent if this is
+ // useful to anybody
+ break;
+
+ default:
+ wxFAIL_MSG( _T("unexpected WM_SIZE parameter") );
+ // fall through nevertheless
+
+ case SIZE_MAXIMIZED:
+ case SIZE_RESTORED:
+ processed = HandleSize(LOWORD(lParam), HIWORD(lParam),
+ wParam);
+ }
+ break;
+
+#ifndef __WXMICROWIN__
+ case WM_ACTIVATEAPP:
+ wxTheApp->SetActive(wParam != 0, FindFocus());
+ break;
+#endif
+
+ case WM_ACTIVATE:
+ {
+ WXWORD state, minimized;
+ WXHWND hwnd;
+ UnpackActivate(wParam, lParam, &state, &minimized, &hwnd);
+
+ processed = HandleActivate(state, minimized != 0, (WXHWND)hwnd);
+ }
+ break;
+
+ case WM_SETFOCUS:
+ processed = HandleSetFocus((WXHWND)(HWND)wParam);
+ break;
+
+ case WM_KILLFOCUS:
+ processed = HandleKillFocus((WXHWND)(HWND)wParam);
+ break;
+
+ case WM_PAINT:
+ processed = HandlePaint();
+ break;
+
+ case WM_CLOSE:
+ // don't let the DefWindowProc() destroy our window - we'll do it
+ // ourselves in ~wxWindow
+ processed = TRUE;
+ rc.result = TRUE;
+ break;
+
+ case WM_SHOWWINDOW:
+ processed = HandleShow(wParam != 0, (int)lParam);
+ break;
+
+ case WM_MOUSEMOVE:
+ processed = HandleMouseMove(GET_X_LPARAM(lParam),
+ GET_Y_LPARAM(lParam),
+ wParam);
+ break;
+
+#if wxUSE_MOUSEWHEEL
+ case WM_MOUSEWHEEL:
+ processed = HandleMouseWheel(wParam, lParam);
+ break;
+#endif
+
+ case WM_LBUTTONDOWN:
+ case WM_LBUTTONUP:
+ case WM_LBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+ case WM_RBUTTONUP:
+ case WM_RBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+ case WM_MBUTTONUP:
+ case WM_MBUTTONDBLCLK:
+ {
+ processed = FALSE;
+#ifdef __WXMICROWIN__
+ // MicroWindows seems to ignore the fact that a window is
+ // disabled. So catch mouse events and throw them away if
+ // necessary.
+ wxWindowMSW* win = this;
+ while (win)
+ {
+ if (!win->IsEnabled())
+ {
+ processed = TRUE;
+ break;
+ }
+ win = win->GetParent();
+ if (win && win->IsTopLevel())
+ break;
+ }
+#endif // __WXMICROWIN__
+ if (!processed)
+ {
+ if (message == WM_LBUTTONDOWN && AcceptsFocus())
+ SetFocus();
+ processed = HandleMouseEvent(message,
+ GET_X_LPARAM(lParam),
+ GET_Y_LPARAM(lParam),
+ wParam);
+ }
+ break;
+ }
+
+#ifdef __WXMICROWIN__
+ case WM_NCLBUTTONDOWN:
+ case WM_NCLBUTTONUP:
+ case WM_NCLBUTTONDBLCLK:
+ case WM_NCRBUTTONDOWN:
+ case WM_NCRBUTTONUP:
+ case WM_NCRBUTTONDBLCLK:
+#if 0
+ case WM_NCMBUTTONDOWN:
+ case WM_NCMBUTTONUP:
+ case WM_NCMBUTTONDBLCLK:
+#endif
+ {
+ // MicroWindows seems to ignore the fact that a window
+ // is disabled. So catch mouse events and throw them away if necessary.
+ processed = FALSE;
+ wxWindowMSW* win = this;
+ while (win)
+ {
+ if (!win->IsEnabled())
+ {
+ processed = TRUE;
+ break;
+ }
+ win = win->GetParent();
+ if (win && win->IsTopLevel())
+ break;
+ }
+ break;
+ }
+#endif // __WXMICROWIN__
+
+#ifdef MM_JOY1MOVE
+ case MM_JOY1MOVE:
+ case MM_JOY2MOVE:
+ case MM_JOY1ZMOVE:
+ case MM_JOY2ZMOVE:
+ case MM_JOY1BUTTONDOWN:
+ case MM_JOY2BUTTONDOWN:
+ case MM_JOY1BUTTONUP:
+ case MM_JOY2BUTTONUP:
+ processed = HandleJoystickEvent(message,
+ GET_X_LPARAM(lParam),
+ GET_Y_LPARAM(lParam),
+ wParam);
+ break;
+#endif // __WXMICROWIN__
+
+ case WM_SYSCOMMAND:
+ processed = HandleSysCommand(wParam, lParam);
+ break;
+
+ case WM_COMMAND:
+ {
+ WORD id, cmd;
+ WXHWND hwnd;
+ UnpackCommand(wParam, lParam, &id, &hwnd, &cmd);
+
+ processed = HandleCommand(id, cmd, hwnd);
+ }
+ break;
+
+#ifdef __WIN95__
+ case WM_NOTIFY:
+ processed = HandleNotify((int)wParam, lParam, &rc.result);
+ break;
+#endif // Win95
+
+ // for these messages we must return TRUE if process the message
+#ifdef WM_DRAWITEM
+ case WM_DRAWITEM:
+ case WM_MEASUREITEM:
+ {
+ int idCtrl = (UINT)wParam;
+ if ( message == WM_DRAWITEM )
+ {
+ processed = MSWOnDrawItem(idCtrl,
+ (WXDRAWITEMSTRUCT *)lParam);
+ }
+ else
+ {
+ processed = MSWOnMeasureItem(idCtrl,
+ (WXMEASUREITEMSTRUCT *)lParam);
+ }
+
+ if ( processed )
+ rc.result = TRUE;
+ }
+ break;
+#endif // defined(WM_DRAWITEM)
+
+ case WM_GETDLGCODE:
+ if ( m_lDlgCode )
+ {
+ rc.result = m_lDlgCode;
+ processed = TRUE;
+ }
+ //else: get the dlg code from the DefWindowProc()
+ break;
+
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+ // If this has been processed by an event handler,
+ // return 0 now (we've handled it).
+ if ( HandleKeyDown((WORD) wParam, lParam) )
+ {
+ processed = TRUE;
+
+ break;
+ }
+
+ // we consider these message "not interesting" to OnChar
+ if ( wParam == VK_SHIFT || wParam == VK_CONTROL )
+ {
+ processed = TRUE;
+
+ break;
+ }
+
+ switch ( wParam )
+ {
+ // avoid duplicate messages to OnChar for these ASCII keys: they
+ // will be translated by TranslateMessage() and received in WM_CHAR
+ case VK_ESCAPE:
+ case VK_SPACE:
+ case VK_RETURN:
+ case VK_BACK:
+ case VK_TAB:
+ case VK_ADD:
+ case VK_SUBTRACT:
+ // but set processed to FALSE, not TRUE to still pass them to
+ // the control's default window proc - otherwise built-in
+ // keyboard handling won't work
+ processed = FALSE;
+
+ break;
+
+#ifdef VK_APPS
+ // special case of VK_APPS: treat it the same as right mouse
+ // click because both usually pop up a context menu
+ case VK_APPS:
+ {
+ WPARAM flags;
+ int x, y;
+
+ TranslateKbdEventToMouse(this, &x, &y, &flags);
+ processed = HandleMouseEvent(WM_RBUTTONDOWN, x, y, flags);
+ }
+ break;
+#endif // VK_APPS
+
+ case VK_LEFT:
+ case VK_RIGHT:
+ case VK_DOWN:
+ case VK_UP:
+ default:
+ processed = HandleChar((WORD)wParam, lParam);
+ }
+ break;
+
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+#ifdef VK_APPS
+ // special case of VK_APPS: treat it the same as right mouse button
+ if ( wParam == VK_APPS )
+ {
+ WPARAM flags;
+ int x, y;
+
+ TranslateKbdEventToMouse(this, &x, &y, &flags);
+ processed = HandleMouseEvent(WM_RBUTTONUP, x, y, flags);
+ }
+ else
+#endif // VK_APPS
+ {
+ processed = HandleKeyUp((WORD) wParam, lParam);
+ }
+ break;
+
+ case WM_SYSCHAR:
+ case WM_CHAR: // Always an ASCII character
+ processed = HandleChar((WORD)wParam, lParam, TRUE);
+ break;
+
+ case WM_HSCROLL:
+ case WM_VSCROLL:
+ {
+ WXWORD code, pos;
+ WXHWND hwnd;
+ UnpackScroll(wParam, lParam, &code, &pos, &hwnd);
+
+ processed = MSWOnScroll(message == WM_HSCROLL ? wxHORIZONTAL
+ : wxVERTICAL,
+ code, pos, hwnd);
+ }
+ break;
+
+ // CTLCOLOR messages are sent by children to query the parent for their
+ // colors#ifndef __WXMICROWIN__
+#ifndef __WXMICROWIN__
+#ifdef __WIN32__
+ case WM_CTLCOLORMSGBOX:
+ case WM_CTLCOLOREDIT:
+ case WM_CTLCOLORLISTBOX:
+ case WM_CTLCOLORBTN:
+ case WM_CTLCOLORDLG:
+ case WM_CTLCOLORSCROLLBAR:
+ case WM_CTLCOLORSTATIC:
+#else // Win16
+ case WM_CTLCOLOR:
+#endif // Win32/16
+ {
+ WXWORD nCtlColor;
+ WXHDC hdc;
+ WXHWND hwnd;
+ UnpackCtlColor(wParam, lParam, &nCtlColor, &hdc, &hwnd);
+
+ processed = HandleCtlColor(&rc.hBrush,
+ (WXHDC)hdc,
+ (WXHWND)hwnd,
+ nCtlColor,
+ message,
+ wParam,
+ lParam);
+ }
+ break;
+#endif // !__WXMICROWIN__
+
+ // the return value for this message is ignored
+ case WM_SYSCOLORCHANGE:
+ processed = HandleSysColorChange();
+ break;
+
+ case WM_PALETTECHANGED:
+ processed = HandlePaletteChanged((WXHWND) (HWND) wParam);
+ break;
+
+ case WM_QUERYNEWPALETTE:
+ processed = HandleQueryNewPalette();
+ break;
+
+ case WM_ERASEBKGND:
+ processed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
+ if ( processed )
+ {
+ // we processed the message, i.e. erased the background
+ rc.result = TRUE;
+ }
+ break;
+
+ case WM_DROPFILES:
+ processed = HandleDropFiles(wParam);
+ break;
+
+ case WM_INITDIALOG:
+ processed = HandleInitDialog((WXHWND)(HWND)wParam);
+
+ if ( processed )
+ {
+ // we never set focus from here
+ rc.result = FALSE;
+ }
+ break;
+
+ case WM_QUERYENDSESSION:
+ processed = HandleQueryEndSession(lParam, &rc.allow);
+ break;
+
+ case WM_ENDSESSION:
+ processed = HandleEndSession(wParam != 0, lParam);
+ break;
+
+ case WM_GETMINMAXINFO:
+ processed = HandleGetMinMaxInfo((MINMAXINFO*)lParam);
+ break;
+
+ case WM_SETCURSOR:
+ processed = HandleSetCursor((WXHWND)(HWND)wParam,
+ LOWORD(lParam), // hit test
+ HIWORD(lParam)); // mouse msg
+
+ if ( processed )
+ {
+ // returning TRUE stops the DefWindowProc() from further
+ // processing this message - exactly what we need because we've
+ // just set the cursor.
+ rc.result = TRUE;
+ }
+ break;
+
+#if defined(__WIN32__) && defined(WM_HELP)
+ case WM_HELP:
+ {
+ HELPINFO* info = (HELPINFO*) lParam;
+ // Don't yet process menu help events, just windows
+ if (info->iContextType == HELPINFO_WINDOW)
+ {
+ wxWindowMSW* subjectOfHelp = this;
+ bool eventProcessed = FALSE;
+ while (subjectOfHelp && !eventProcessed)
+ {
+ wxHelpEvent helpEvent(wxEVT_HELP,
+ subjectOfHelp->GetId(),
+ wxPoint(info->MousePos.x,
+ info->MousePos.y) );
+ helpEvent.SetEventObject(this);
+ eventProcessed =
+ GetEventHandler()->ProcessEvent(helpEvent);
+
+ // Go up the window hierarchy until the event is
+ // handled (or not)
+ subjectOfHelp = subjectOfHelp->GetParent();
+ }
+
+ processed = eventProcessed;
+ }
+ else if (info->iContextType == HELPINFO_MENUITEM)
+ {
+ wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId);
+ helpEvent.SetEventObject(this);
+ processed = GetEventHandler()->ProcessEvent(helpEvent);
+
+ }
+ //else: processed is already FALSE
+ }
+ break;
+
+ case WM_CONTEXTMENU:
+ {
+ // we don't convert from screen to client coordinates as
+ // the event may be handled by a parent window
+ wxPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+
+ wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, GetId(), pt);
+ processed = GetEventHandler()->ProcessEvent(evtCtx);
+ }
+ break;
+#endif // __WIN32__
+
+ // unfortunately this doesn't really work as then window which
+ // doesn't accept focus doesn't get any mouse events neither which
+ // means it can't get any input at all
+#if 0 //def __WXUNIVERSAL__
+ case WM_NCHITTEST:
+ // we shouldn't allow the windows which don't want to get focus to
+ // get it
+ if ( !AcceptsFocus() )
+ {
+ rc.result = HTTRANSPARENT;
+ processed = TRUE;
+ }
+ break;
+#endif // __WXUNIVERSAL__
+ }
+
+ if ( !processed )
+ {
+#ifdef __WXDEBUG__
+ wxLogTrace(wxTraceMessages, wxT("Forwarding %s to DefWindowProc."),
+ wxGetMessageName(message));
+#endif // __WXDEBUG__
+ rc.result = MSWDefWindowProc(message, wParam, lParam);
+ }
+
+ return rc.result;
+}
+
+// ----------------------------------------------------------------------------
+// wxWindow <-> HWND map
+// ----------------------------------------------------------------------------
+
+wxWinHashTable *wxWinHandleHash = NULL;
+
+wxWindow *wxFindWinFromHandle(WXHWND hWnd)
+{
+ return wxWinHandleHash->Get((long)hWnd);
+}
+
+void wxAssociateWinWithHandle(HWND hWnd, wxWindowMSW *win)
+{
+ // adding NULL hWnd is (first) surely a result of an error and
+ // (secondly) breaks menu command processing
+ wxCHECK_RET( hWnd != (HWND)NULL,
+ wxT("attempt to add a NULL hWnd to window list ignored") );
+
+ wxWindow *oldWin = wxFindWinFromHandle((WXHWND) hWnd);
+#ifdef __WXDEBUG__
+ if ( oldWin && (oldWin != win) )
+ {
+ wxLogDebug(wxT("HWND %X already associated with another window (%s)"),
+ hWnd, win->GetClassInfo()->GetClassName());
+ }
+ else
+#endif // __WXDEBUG__
+ if (!oldWin)
+ {
+ wxWinHandleHash->Put((long)hWnd, (wxWindow *)win);
+ }
+}
+
+void wxRemoveHandleAssociation(wxWindowMSW *win)
+{
+ wxWinHandleHash->Delete((long)win->GetHWND());
+}
+
+// ----------------------------------------------------------------------------
+// various MSW speciic class dependent functions
+// ----------------------------------------------------------------------------
+
+// Default destroyer - override if you destroy it in some other way
+// (e.g. with MDI child windows)
+void wxWindowMSW::MSWDestroyWindow()
+{
+}
+
+void wxWindowMSW::MSWDetachWindowMenu()
+{
+#ifndef __WXUNIVERSAL__
+ if ( m_hMenu )
+ {
+ wxChar buf[1024];
+ HMENU hMenu = (HMENU)m_hMenu;
+
+ int N = ::GetMenuItemCount(hMenu);
+ for ( int i = 0; i < N; i++ )
+ {
+ if ( !::GetMenuString(hMenu, i, buf, WXSIZEOF(buf), MF_BYPOSITION) )
+ {
+ wxLogLastError(wxT("GetMenuString"));
+
+ continue;
+ }