Click here to Skip to main content
15,897,968 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Question about typecast Pin
Richard Andrew x646-Apr-06 10:02
professionalRichard Andrew x646-Apr-06 10:02 
GeneralRe: Question about typecast Pin
David Crow6-Apr-06 10:36
David Crow6-Apr-06 10:36 
Questionserial port communication in embedded visual c++ Pin
neha_vi216-Apr-06 8:30
neha_vi216-Apr-06 8:30 
QuestionNewbie question Pin
cdengler6-Apr-06 8:24
cdengler6-Apr-06 8:24 
AnswerRe: Newbie question Pin
David Crow6-Apr-06 10:42
David Crow6-Apr-06 10:42 
GeneralRe: Newbie question Pin
Richard Andrew x646-Apr-06 11:45
professionalRichard Andrew x646-Apr-06 11:45 
QuestionToolbar border in dialog question Pin
Cpt Rick6-Apr-06 8:24
Cpt Rick6-Apr-06 8:24 
QuestionCTooltipCtrl for a modeless dialog in a DLL Pin
madmax00016-Apr-06 7:49
madmax00016-Apr-06 7:49 
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 && 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;
}

// Process WM_MOUSE messages for tooltips here ????
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 mousemessage handling is wrong, because CCombobox controls can't be opened (They open very short and automatically close again).


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

THX
QuestionInteresting Windows Architecture Questions Pin
Richard Andrew x646-Apr-06 7:47
professionalRichard Andrew x646-Apr-06 7:47 
QuestionPropertyPage Help Pin
NYTSX6-Apr-06 7:28
NYTSX6-Apr-06 7:28 
QuestionRe: PropertyPage Help Pin
David Crow6-Apr-06 7:42
David Crow6-Apr-06 7:42 
AnswerRe: PropertyPage Help Pin
NYTSX6-Apr-06 7:55
NYTSX6-Apr-06 7:55 
GeneralRe: PropertyPage Help Pin
David Crow6-Apr-06 8:17
David Crow6-Apr-06 8:17 
GeneralRe: PropertyPage Help Pin
NYTSX6-Apr-06 8:27
NYTSX6-Apr-06 8:27 
GeneralRe: PropertyPage Help Pin
David Crow6-Apr-06 8:35
David Crow6-Apr-06 8:35 
GeneralRe: PropertyPage Help Pin
NYTSX6-Apr-06 9:41
NYTSX6-Apr-06 9:41 
GeneralRe: PropertyPage Help Pin
David Crow6-Apr-06 10:38
David Crow6-Apr-06 10:38 
Questionlord of the sockets please help Pin
nahitan6-Apr-06 7:26
nahitan6-Apr-06 7:26 
AnswerRe: lord of the sockets please help Pin
Richard Andrew x646-Apr-06 8:00
professionalRichard Andrew x646-Apr-06 8:00 
QuestionDialog based application with background Pin
Rostfrei6-Apr-06 6:31
Rostfrei6-Apr-06 6:31 
AnswerRe: Dialog based application with background Pin
Hamid_RT6-Apr-06 6:45
Hamid_RT6-Apr-06 6:45 
AnswerRe: Dialog based application with background Pin
Hamid_RT6-Apr-06 6:52
Hamid_RT6-Apr-06 6:52 
GeneralRe: Dialog based application with background Pin
Rostfrei6-Apr-06 7:45
Rostfrei6-Apr-06 7:45 
GeneralRe: Dialog based application with background Pin
Rostfrei6-Apr-06 8:59
Rostfrei6-Apr-06 8:59 
QuestionCall a function from provided DLL Pin
BenHieu6-Apr-06 6:25
BenHieu6-Apr-06 6:25 

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.