CTooltipCtrl for a modeless dialog in a DLL
-
Hi, me again... a few days a go I posted a problem with showing tooltips in a modeless dialog in a dll. I got a hint which seems to solve the problem. I have done several tests in the meantime and unfortunatelly there is still a small problem with the tooltip. To setup the tooltips for the modeless dialog in my dll I use this function: ////////////////////////////////////////// void CMyDialog::SetToolTip(CWnd* pWnd, LPCTSTR lpszText) { if((pWnd != NULL) && (m_pTip != NULL)){ TOOLINFO ti; ti.cbSize = sizeof(TOOLINFO); ti.lpszText = (LPTSTR)lpszText; ti.hinst = AfxGetInstanceHandle(); ti.hwnd = pWnd->m_hWnd; ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND; ti.uId = (UINT)pWnd->m_hWnd; m_pTip->SendMessage(TTM_ADDTOOL, 0, (LPARAM)&ti); } } ////////////////////////////////////////// THe tooltip is shown and this works without (!) any call to CMyDialog::PreTranslateMessage(MSG* pMsg) and RelayEvent. But I need this call, because there is an MFC bug with tooltips for disabled controls and I used in my other modal dialogs this code: ////////////////////////////////////////// BOOL CMyDialog::PreTranslateMessage(MSG* pMsg) { TRACE("PreTranslateMessage\n"); if(m_pTip != NULL){ // The following code is a workaround for a MFC tooltip bug which // prevents the popup of a tooltip for a disabled control in a modal dialog. // Transate the message based on TTM_WINDOWFROMPOINT MSG msg = *pMsg; msg.hwnd = (HWND)m_pTip->SendMessage(TTM_WINDOWFROMPOINT, 0, (LPARAM)&msg.pt); CPoint pt = pMsg->pt; if((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST)) ::ScreenToClient(msg.hwnd, &pt); msg.lParam = MAKELONG(pt.x, pt.y); // Let the ToolTip process this message. m_pTip->RelayEvent(&msg); } // if return CDialog::PreTranslateMessage(pMsg); } ////////////////////////////////////////// Then I tried to use the message hook which was neccessary to use accellerators in CMyDialog to call PreTranslateMessage: ////////////////////////////////////////// // Hook procedure for WH_GETMESSAGE hook type. LRESULT CALLBACK GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam) // If this is a keystrokes message, translate it in controls' // PreTranslateMessage(). LPMSG lpMsg = (LPMSG)lParam; if((nCode >= 0) && (PM_REMOVE == wParam) && (lpMsg->message >= WM_KEYFIRST && l