added Remove(HWND); removed unused wParam parameter from SendTooltipMessage

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39027 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-05-04 15:51:38 +00:00
parent 60c84f8501
commit 0c5405b727
2 changed files with 27 additions and 22 deletions

View File

@@ -45,6 +45,9 @@ public:
// add a window to the tooltip control // add a window to the tooltip control
void Add(WXHWND hwnd); void Add(WXHWND hwnd);
// remove any tooltip from the window
static void Remove(WXHWND hwnd);
private: private:
// the one and only one tooltip control we use - never access it directly // the one and only one tooltip control we use - never access it directly
// but use GetToolTipCtrl() which will create it when needed // but use GetToolTipCtrl() which will create it when needed

View File

@@ -103,23 +103,20 @@ public:
// private functions // private functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// send a message to the tooltip control // send a message to the tooltip control if it exists
inline LRESULT SendTooltipMessage(WXHWND hwnd, //
UINT msg, // NB: wParam is always 0 for the TTM_XXX messages we use
WPARAM wParam, static inline LRESULT SendTooltipMessage(WXHWND hwnd, UINT msg, void *lParam)
void *lParam)
{ {
return hwnd ? ::SendMessage((HWND)hwnd, msg, wParam, (LPARAM)lParam) return hwnd ? ::SendMessage((HWND)hwnd, msg, 0, (LPARAM)lParam) : 0;
: 0;
} }
// send a message to all existing tooltip controls // send a message to all existing tooltip controls
static void SendTooltipMessageToAll(WXHWND hwnd, static inline void
UINT msg, SendTooltipMessageToAll(WXHWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
WPARAM wParam,
LPARAM lParam)
{ {
(void)SendTooltipMessage((WXHWND)hwnd, msg, wParam, (void *)lParam); if ( hwnd )
::SendMessage((HWND)hwnd, msg, wParam, lParam);
} }
// ============================================================================ // ============================================================================
@@ -227,7 +224,7 @@ WXHWND wxToolTip::GetToolTipCtrl()
void wxToolTip::RelayEvent(WXMSG *msg) void wxToolTip::RelayEvent(WXMSG *msg)
{ {
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_RELAYEVENT, 0, msg); (void)SendTooltipMessage(GetToolTipCtrl(), TTM_RELAYEVENT, msg);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -253,13 +250,18 @@ wxToolTip::~wxToolTip()
// others // others
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxToolTip::Remove(WXHWND hWnd)
{
wxToolInfo ti((HWND)hWnd);
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_DELTOOL, &ti);
}
void wxToolTip::Remove() void wxToolTip::Remove()
{ {
// remove this tool from the tooltip control // remove this tool from the tooltip control
if ( m_window ) if ( m_window )
{ {
wxToolInfo ti(GetHwndOf(m_window)); Remove(m_window->GetHWND());
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_DELTOOL, 0, &ti);
} }
} }
@@ -278,7 +280,7 @@ void wxToolTip::Add(WXHWND hWnd)
ti.hwnd = hwnd; ti.hwnd = hwnd;
ti.lpszText = (wxChar *)m_text.c_str(); // const_cast ti.lpszText = (wxChar *)m_text.c_str(); // const_cast
if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) ) if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) )
{ {
wxLogDebug(_T("Failed to create the tooltip '%s'"), m_text.c_str()); wxLogDebug(_T("Failed to create the tooltip '%s'"), m_text.c_str());
} }
@@ -294,9 +296,9 @@ void wxToolTip::Add(WXHWND hWnd)
{ {
// use TTM_SETMAXTIPWIDTH to make tooltip multiline using the // use TTM_SETMAXTIPWIDTH to make tooltip multiline using the
// extent of its first line as max value // extent of its first line as max value
HFONT hfont = (HFONT)SendTooltipMessage(GetToolTipCtrl(), HFONT hfont = (HFONT)
WM_GETFONT, SendTooltipMessage(GetToolTipCtrl(), WM_GETFONT, 0);
0, 0);
if ( !hfont ) if ( !hfont )
{ {
hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
@@ -324,7 +326,7 @@ void wxToolTip::Add(WXHWND hWnd)
} }
SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH, SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH,
0, (void *)sz.cx); (void *)sz.cx);
} }
else else
#endif // comctl32.dll >= 4.70 #endif // comctl32.dll >= 4.70
@@ -334,7 +336,7 @@ void wxToolTip::Add(WXHWND hWnd)
m_text.Replace(_T("\n"), _T(" ")); m_text.Replace(_T("\n"), _T(" "));
ti.lpszText = (wxChar *)m_text.c_str(); // const_cast ti.lpszText = (wxChar *)m_text.c_str(); // const_cast
if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) ) if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) )
{ {
wxLogDebug(_T("Failed to create the tooltip '%s'"), m_text.c_str()); wxLogDebug(_T("Failed to create the tooltip '%s'"), m_text.c_str());
} }
@@ -408,7 +410,7 @@ void wxToolTip::SetTip(const wxString& tip)
wxToolInfo ti(GetHwndOf(m_window)); wxToolInfo ti(GetHwndOf(m_window));
ti.lpszText = (wxChar *)m_text.c_str(); ti.lpszText = (wxChar *)m_text.c_str();
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti); (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, &ti);
} }
} }