diff --git a/include/wx/msw/combobox.h b/include/wx/msw/combobox.h index 67a49e1e76..e0874993ea 100644 --- a/include/wx/msw/combobox.h +++ b/include/wx/msw/combobox.h @@ -81,6 +81,8 @@ public: virtual bool MSWCommand(WXUINT param, WXWORD id); bool MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam); + WXHWND GetEditHWND() const; + protected: virtual void DoMoveWindow(int x, int y, int width, int height); virtual wxSize DoGetBestSize() const; diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index 5b5df687ed..c50ea3126a 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -38,6 +38,13 @@ #include "wx/clipbrd.h" #include "wx/msw/private.h" +#if wxUSE_TOOLTIPS + #ifndef __GNUWIN32_OLD__ + #include + #endif + #include "wx/tooltip.h" +#endif // wxUSE_TOOLTIPS + // ---------------------------------------------------------------------------- // wxWin macros // ---------------------------------------------------------------------------- @@ -73,15 +80,45 @@ LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd, WPARAM wParam, LPARAM lParam) { - if ( message == WM_CHAR ) + if ( + message == WM_CHAR +#if wxUSE_TOOLTIPS + || message == WM_NOTIFY +#endif // wxUSE_TOOLTIPS + ) { HWND hwndCombo = ::GetParent(hWnd); wxWindow *win = wxFindWinFromHandle((WXHWND)hwndCombo); wxComboBox *combo = wxDynamicCast(win, wxComboBox); wxCHECK_MSG( combo, 0, _T("should have combo as parent") ); - if ( combo->MSWProcessEditMsg(message, wParam, lParam) ) - return 0; + switch ( message ) + { + case WM_CHAR: + if ( combo->MSWProcessEditMsg(message, wParam, lParam) ) + return 0; + break; + +#if wxUSE_TOOLTIPS + case WM_NOTIFY: + { + NMHDR* hdr = (NMHDR *)lParam; + if ( (int)hdr->code == TTN_NEEDTEXT ) + { + wxToolTip *tooltip = combo->GetToolTip(); + if ( tooltip ) + { + TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam; + ttt->lpszText = (wxChar *)tooltip->GetTip().c_str(); + } + + // processed + return 0; + } + } + break; +#endif // wxUSE_TOOLTIPS + } } return ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, hWnd, message, wParam, lParam); @@ -131,6 +168,22 @@ bool wxComboBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) return FALSE; } +WXHWND wxComboBox::GetEditHWND() const +{ + if ( GetWindowStyle() & wxCB_READONLY ) + return NULL; + + POINT pt; + pt.x = pt.y = 4; + HWND hwndEdit = ::ChildWindowFromPoint(GetHwnd(), pt); + if ( !hwndEdit || hwndEdit == GetHwnd() ) + { + wxFAIL_MSG(_T("not read only combobox without edit control?")); + } + + return (WXHWND)hwndEdit; +} + bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, const wxPoint& pos, @@ -182,23 +235,12 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, // edit control, we must subclass it as well if ( !(style & wxCB_READONLY) ) { - // first find the child edit - POINT pt; - pt.x = pt.y = 4; - HWND hwndEdit = ::ChildWindowFromPoint(GetHwnd(), pt); - if ( !hwndEdit || hwndEdit == GetHwnd() ) - { - wxFAIL_MSG(_T("not read only combobox without edit control?")); - } - else - { - gs_wndprocEdit = (WXFARPROC)::SetWindowLong - ( - hwndEdit, - GWL_WNDPROC, - (LPARAM)wxComboEditWndProc - ); - } + gs_wndprocEdit = (WXFARPROC)::SetWindowLong + ( + (HWND)GetEditHWND(), + GWL_WNDPROC, + (LPARAM)wxComboEditWndProc + ); } return TRUE; diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 784f315628..8f35a0f07e 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -582,17 +582,20 @@ bool wxMDIParentFrame::MSWTranslateMessage(WXMSG* msg) { MSG *pMsg = (MSG *)msg; + // first let the current child get it if ( m_currentChild && m_currentChild->GetHWND() && m_currentChild->MSWTranslateMessage(msg) ) { return TRUE; } - if ( m_acceleratorTable.Translate(this, msg) ) + // then try out accel table (will also check the menu accels) + if ( wxFrame::MSWTranslateMessage(msg) ) { return TRUE; } + // finally, check for MDI specific built in accel keys if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN ) { if ( ::TranslateMDISysAccel(GetWinHwnd(GetClientWindow()), pMsg)) diff --git a/src/msw/statbr95.cpp b/src/msw/statbr95.cpp index d314ae41b5..64b9373220 100644 --- a/src/msw/statbr95.cpp +++ b/src/msw/statbr95.cpp @@ -71,6 +71,8 @@ LRESULT APIENTRY wxStatusBarProc(HWND hwnd, { switch (message) { case WM_COMMAND: + case WM_DRAWITEM: + case WM_MEASUREITEM: case WM_SIZE: case WM_MOVE: case WM_MOUSEMOVE: diff --git a/src/msw/tooltip.cpp b/src/msw/tooltip.cpp index 26d31d7ecb..0e69c00abe 100644 --- a/src/msw/tooltip.cpp +++ b/src/msw/tooltip.cpp @@ -374,6 +374,21 @@ void wxToolTip::SetWindow(wxWindow *win) Add((WXHWND)hwnd); } } + + // VZ: it's ugly to do it here, but I don't want any major changes right + // now, later we will probably want to have wxWindow::OnGotToolTip() or + // something like this where the derived class can do such things + // itself instead of wxToolTip "knowing" about them all + wxComboBox *combo = wxDynamicCast(control, wxComboBox); + if ( combo ) + { + WXHWND hwndComboEdit = combo->GetEditHWND(); + if ( hwndComboEdit ) + { + Add(hwndComboEdit); + } + //else: it's ok for a combo to be read only, of course + } } void wxToolTip::SetTip(const wxString& tip)