+ // First check if this applies to us
+ NMHDR *hdr = (NMHDR *)lParam;
+
+ // the tooltips control created by the toolbar is sometimes Unicode, even
+ // in an ANSI application - this seems to be a bug in comctl32.dll v5
+ int code = (int)hdr->code;
+ if ( (code != TTN_NEEDTEXTA) && (code != TTN_NEEDTEXTW) )
+ return FALSE;
+
+ HWND toolTipWnd = (HWND)::SendMessage((HWND)GetHWND(), TB_GETTOOLTIPS, 0, 0);
+ if ( toolTipWnd != hdr->hwndFrom )
+ return FALSE;
+
+ LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam;
+ int id = (int)ttText->hdr.idFrom;
+ wxNode *node = m_tools.Find((long)id);
+ if (!node)
+ return FALSE;
+
+ wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+
+ const wxString& help = tool->m_shortHelpString;
+
+ if ( !help.IsEmpty() )
+ {
+ if ( code == TTN_NEEDTEXTA )
+ {
+ ttText->lpszText = (wxChar *)help.c_str();
+ }
+#if (_WIN32_IE >= 0x0300)
+ else
+ {
+ // FIXME this is a temp hack only until I understand better what
+ // must be done in both ANSI and Unicode builds
+
+ size_t lenAnsi = help.Len();
+ #ifdef __MWERKS__
+ // MetroWerks doesn't like calling mbstowcs with NULL argument
+ size_t lenUnicode = 2*lenAnsi;
+ #else
+ size_t lenUnicode = mbstowcs(NULL, help, lenAnsi);
+ #endif
+
+ // using the pointer of right type avoids us doing all sorts of
+ // pointer arithmetics ourselves
+ wchar_t *dst = (wchar_t *)ttText->szText,
+ *pwz = new wchar_t[lenUnicode + 1];
+ mbstowcs(pwz, help, lenAnsi + 1);
+ memcpy(dst, pwz, lenUnicode*sizeof(wchar_t));
+
+ // put the terminating _wide_ NUL
+ dst[lenUnicode] = 0;
+
+ delete [] pwz;
+ }
+#endif // _WIN32_IE >= 0x0300
+ }
+
+ // For backward compatibility...
+ OnMouseEnter(tool->m_index);
+
+ return TRUE;