Click here to Skip to main content
15,903,362 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionBuffer Size and Other Parameters! Pin
student_eng31-Mar-06 8:34
student_eng31-Mar-06 8:34 
AnswerRe: Buffer Size and Other Parameters! Pin
David Crow31-Mar-06 9:16
David Crow31-Mar-06 9:16 
QuestionCToolTipCtrl in modeless dialog ??? Pin
madmax000131-Mar-06 7:51
madmax000131-Mar-06 7:51 
QuestionRe: CToolTipCtrl in modeless dialog ??? Pin
David Crow31-Mar-06 7:55
David Crow31-Mar-06 7:55 
AnswerRe: CToolTipCtrl in modeless dialog ??? Pin
madmax000131-Mar-06 9:58
madmax000131-Mar-06 9:58 
AnswerRe: CToolTipCtrl in modeless dialog ??? Pin
Hamid_RT31-Mar-06 8:43
Hamid_RT31-Mar-06 8:43 
GeneralRe: CToolTipCtrl in modeless dialog ??? Pin
madmax000131-Mar-06 9:59
madmax000131-Mar-06 9:59 
GeneralRe: CToolTipCtrl in modeless dialog ??? Pin
madmax00016-Apr-06 6:36
madmax00016-Apr-06 6:36 
Hi, me again...

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);
}
}
//////////////////////////////////////////

This works without (!) any call to CMyDialog::PreTranslateMessage(MSG* pMsg). But I need this call, because there is an MFC bug with tooltips for disabled controls and I used in my 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:

//////////////////////////////////////////
// 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 && lpMsg->message <= WM_KEYLAST) &&
(AfxGetApp()->PreTranslateMessage((LPMSG)lParam)) == TRUE){
// The value returned from this hookproc is ignored, and it cannot
// be used to tell Windows the message has been handled. To avoid
// further processing, convert the message to WM_NULL before
// returning.
lpMsg->message = WM_NULL;
lpMsg->lParam = 0L;
lpMsg->wParam = 0;
}

if((nCode >= 0) &&
(PM_REMOVE == wParam) &&
(lpMsg->message >= WM_MOUSEFIRST && lpMsg->message <= WM_MOUSELAST) &&
(AfxGetApp()->PreTranslateMessage((LPMSG)lParam)) == TRUE){

// Do nothing ???


}
// Passes the hook information to the next hook procedure in
// the current hook chain.
return ::CallNextHookEx(g_hHook, nCode, wParam, lParam);
}
//////////////////////////////////////////

When I use the above code the tooltips for disabled controls work, but something with the mosemessage handling is wrong, because CCombobox Controls can't be opened.


Does anyone kwon how to solve my problem ?? I think somehow I must call RelayEvent of the tooltip.

THX


GeneralRe: CToolTipCtrl in modeless dialog ??? Pin
Albertino17-Apr-14 23:36
Albertino17-Apr-14 23:36 
AnswerRe: CToolTipCtrl in modeless dialog ??? Pin
madmax00016-Apr-06 6:42
madmax00016-Apr-06 6:42 
QuestionHelp with multi-sort Pin
Kurt _B31-Mar-06 6:13
Kurt _B31-Mar-06 6:13 
AnswerRe: Help with multi-sort Pin
FarPointer31-Mar-06 7:06
FarPointer31-Mar-06 7:06 
GeneralRe: Help with multi-sort Pin
Kurt _B31-Mar-06 7:10
Kurt _B31-Mar-06 7:10 
GeneralRe: Help with multi-sort Pin
FarPointer31-Mar-06 7:16
FarPointer31-Mar-06 7:16 
GeneralRe: Help with multi-sort Pin
David Crow31-Mar-06 7:39
David Crow31-Mar-06 7:39 
GeneralRe: Help with multi-sort Pin
David Crow31-Mar-06 7:14
David Crow31-Mar-06 7:14 
GeneralRe: Help with multi-sort Pin
FarPointer31-Mar-06 7:19
FarPointer31-Mar-06 7:19 
GeneralRe: Help with multi-sort Pin
David Crow31-Mar-06 7:31
David Crow31-Mar-06 7:31 
GeneralRe: Help with multi-sort Pin
FarPointer31-Mar-06 7:35
FarPointer31-Mar-06 7:35 
GeneralRe: Help with multi-sort Pin
Maximilien31-Mar-06 10:16
Maximilien31-Mar-06 10:16 
GeneralRe: Help with multi-sort Pin
Kurt _B31-Mar-06 7:23
Kurt _B31-Mar-06 7:23 
GeneralRe: Help with multi-sort Pin
David Crow31-Mar-06 7:38
David Crow31-Mar-06 7:38 
GeneralRe: Help with multi-sort Pin
FarPointer31-Mar-06 7:43
FarPointer31-Mar-06 7:43 
QuestionCallback to MFC App from MFC DLL Pin
b_p_smith31-Mar-06 5:48
b_p_smith31-Mar-06 5:48 
AnswerRe: Callback to MFC App from MFC DLL Pin
Kurt _B31-Mar-06 6:05
Kurt _B31-Mar-06 6:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.