X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0ce0f1e9eb40774b86bf50dd05230857d87372b0..739c5499fcab1c165b8dd0591c9fd9e2329b3cf9:/src/msw/tooltip.cpp diff --git a/src/msw/tooltip.cpp b/src/msw/tooltip.cpp index e9e84c7621..349998f1d5 100644 --- a/src/msw/tooltip.cpp +++ b/src/msw/tooltip.cpp @@ -357,7 +357,7 @@ void wxToolTip::Remove(WXHWND hWnd, unsigned int id, const wxRect& rc) void wxToolTip::DoRemove(WXHWND hWnd) { - if ( hWnd == m_window->GetHWND() ) + if ( m_window && hWnd == m_window->GetHWND() ) { // Remove the tooltip from the main window. Remove(hWnd, m_id, m_rect); @@ -374,17 +374,17 @@ void wxToolTip::Remove() DoForAllWindows(&wxToolTip::DoRemove); } -void wxToolTip::Add(WXHWND hWnd) +void wxToolTip::AddOtherWindow(WXHWND hWnd) { if ( !m_others ) m_others = new wxToolTipOtherWindows; m_others->push_back(hWnd); - DoAddOtherWindow(hWnd); + DoAddHWND(hWnd); } -void wxToolTip::DoAddOtherWindow(WXHWND hWnd) +void wxToolTip::DoAddHWND(WXHWND hWnd) { HWND hwnd = (HWND)hWnd; @@ -397,7 +397,7 @@ void wxToolTip::DoAddOtherWindow(WXHWND hWnd) // NMTTDISPINFO struct -- and setting the tooltip here we can have tooltips // of any length ti.hwnd = hwnd; - ti.lpszText = const_cast(m_text.wx_str()); + ti.lpszText = wxMSW_CONV_LPTSTR(m_text); if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) ) { @@ -442,7 +442,7 @@ void wxToolTip::DoAddOtherWindow(WXHWND hWnd) const wxString token = tokenizer.GetNextToken(); SIZE sz; - if ( !::GetTextExtentPoint32(hdc, token.wx_str(), + if ( !::GetTextExtentPoint32(hdc, token.t_str(), token.length(), &sz) ) { wxLogLastError(wxT("GetTextExtentPoint32")); @@ -484,7 +484,7 @@ void wxToolTip::DoAddOtherWindow(WXHWND hWnd) // replace the '\n's with spaces because otherwise they appear as // unprintable characters in the tooltip string m_text.Replace(wxT("\n"), wxT(" ")); - ti.lpszText = const_cast(m_text.wx_str()); + ti.lpszText = wxMSW_CONV_LPTSTR(m_text); if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) ) { @@ -502,7 +502,7 @@ void wxToolTip::SetWindow(wxWindow *win) // add the window itself if ( m_window ) { - Add(m_window->GetHWND()); + DoAddHWND(m_window->GetHWND()); } #if !defined(__WXUNIVERSAL__) // and all of its subcontrols (e.g. radio buttons in a radiobox) as well @@ -526,7 +526,7 @@ void wxToolTip::SetWindow(wxWindow *win) // must have it by now! wxASSERT_MSG( hwnd, wxT("no hwnd for subcontrol?") ); - Add((WXHWND)hwnd); + AddOtherWindow((WXHWND)hwnd); } } #endif // !defined(__WXUNIVERSAL__) @@ -561,21 +561,17 @@ void wxToolTip::DoSetTip(WXHWND hWnd) ti.lpszText = const_cast(wxT("")); (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, &ti); - ti.lpszText = const_cast(m_text.wx_str()); + ti.lpszText = wxMSW_CONV_LPTSTR(m_text); (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, &ti); } void wxToolTip::DoForAllWindows(void (wxToolTip::*func)(WXHWND)) { - if ( !m_window ) + if ( m_window ) { - wxASSERT_MSG( !m_others, - wxS("Can't have other windows without the main one.") ); - return; + (this->*func)(m_window->GetHWND()); } - (this->*func)(m_window->GetHWND()); - if ( m_others ) { for ( wxToolTipOtherWindows::const_iterator it = m_others->begin();