J
JuliaQQ
Guest
Hello,
I met a question about the tooltips in modeless dialog dll.
I use the method to set a hook in my dll. MSDN Link:"The TAB key doesnt move input focus from one control to another. Pressing the arrow keys or accelerator keys in the modeless dialog box or propertysheet window has no effect."
But the result cannt meet my requirement. The tool tip just show a flash, not more then one second. I want them as model dialogs tooltips do. when the mouse leave the tool tips disappear.
I have try all methods I thought which could fix it, but in vain. Such as "Sleep(100)".
Maybe the hook interrupt by Onpaint()? I dont know.
I have no idea about what is the problem. Could you tell me what the problem is?
Thank you very much in advance.
in dlg.h to declaration
CToolTipCtrl* m_pToolTip;
in dlg.cpp to initialize and delete
CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CWeldMainDlg::IDD, pParent)
{
m_pToolTip = NULL;
}
CTestDlg::~CTestDlg()
{
delete m_pToolTip;
}
OnInitDialog()
{
m_pToolTip = new CToolTipCtrl;
EnableToolTips(TRUE);
if(!m_pToolTip->Create(this))
{
TRACE("Unable To create ToolTip\n");
return TRUE;
}
pWnd = GetDlgItem(IDC_EDIT1);
if (!m_pToolTip->AddTool(pWnd,"root"))
{
AfxMessageBox("Error creating Dialog");
}
m_pToolTip->Activate(TRUE);
}
PreTranslateMessage(MSG* pMsg)
{
if (NULL != m_pToolTip)
m_pToolTip->RelayEvent(pMsg);
return CDialog:reTranslateMessage(pMsg);
}
After above code, Model dialog Dll could show tooltips, but the modeless dialog dll cant show tooltip.
I also add tooltips message map to the DLL.
ON_NOTIFY_EX(TTN_NEEDTEXT, IDC_EDIT1, &CTestDlg::OnToolTipText)
OnToolTipText()
{
}
I put a break point in the "OnToolTipText", it dont be called. so I think it doesnt call the OnToolTipText function.
I add a hook in the DLL.
.cpp
a global var.
HHOOK hHook = NULL;
hook function
LRESULT CALLBACK __stdcall GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
LPMSG lpMsg = (LPMSG) lParam;
if( (nCode >= 0) )
{
CWnd *pWnd = CWnd::FromHandlePermanent(lpMsg->hwnd);
if (pWnd) // a CWnd exists
pWnd->PreTranslateMessage(lpMsg);
}
return ::CallNextHookEx(hHook, nCode, wParam, lParam);
}
BOOL CWeldMainDlg::OnInitDialog()
{
CDialog::OnInitDialog();
hHook = ::SetWindowsHookEx(
WH_GETMESSAGE,
GetMessageProc,
AfxGetInstanceHandle(),
GetCurrentThreadId());
ASSERT (hHook);
.......
}
After that, the tooltips can show in the modeless dialog, but just a flash. when you dont move your mouse in the IDC_EDIT1, the tooltips can show no more than one second and disappear. you should move mouse back
to let the tooltips show a flash.
Continue reading...
I met a question about the tooltips in modeless dialog dll.
I use the method to set a hook in my dll. MSDN Link:"The TAB key doesnt move input focus from one control to another. Pressing the arrow keys or accelerator keys in the modeless dialog box or propertysheet window has no effect."
But the result cannt meet my requirement. The tool tip just show a flash, not more then one second. I want them as model dialogs tooltips do. when the mouse leave the tool tips disappear.
I have try all methods I thought which could fix it, but in vain. Such as "Sleep(100)".
Maybe the hook interrupt by Onpaint()? I dont know.
I have no idea about what is the problem. Could you tell me what the problem is?
Thank you very much in advance.
in dlg.h to declaration
CToolTipCtrl* m_pToolTip;
in dlg.cpp to initialize and delete
CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CWeldMainDlg::IDD, pParent)
{
m_pToolTip = NULL;
}
CTestDlg::~CTestDlg()
{
delete m_pToolTip;
}
OnInitDialog()
{
m_pToolTip = new CToolTipCtrl;
EnableToolTips(TRUE);
if(!m_pToolTip->Create(this))
{
TRACE("Unable To create ToolTip\n");
return TRUE;
}
pWnd = GetDlgItem(IDC_EDIT1);
if (!m_pToolTip->AddTool(pWnd,"root"))
{
AfxMessageBox("Error creating Dialog");
}
m_pToolTip->Activate(TRUE);
}
PreTranslateMessage(MSG* pMsg)
{
if (NULL != m_pToolTip)
m_pToolTip->RelayEvent(pMsg);
return CDialog:reTranslateMessage(pMsg);
}
After above code, Model dialog Dll could show tooltips, but the modeless dialog dll cant show tooltip.
I also add tooltips message map to the DLL.
ON_NOTIFY_EX(TTN_NEEDTEXT, IDC_EDIT1, &CTestDlg::OnToolTipText)
OnToolTipText()
{
}
I put a break point in the "OnToolTipText", it dont be called. so I think it doesnt call the OnToolTipText function.
I add a hook in the DLL.
.cpp
a global var.
HHOOK hHook = NULL;
hook function
LRESULT CALLBACK __stdcall GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
LPMSG lpMsg = (LPMSG) lParam;
if( (nCode >= 0) )
{
CWnd *pWnd = CWnd::FromHandlePermanent(lpMsg->hwnd);
if (pWnd) // a CWnd exists
pWnd->PreTranslateMessage(lpMsg);
}
return ::CallNextHookEx(hHook, nCode, wParam, lParam);
}
BOOL CWeldMainDlg::OnInitDialog()
{
CDialog::OnInitDialog();
hHook = ::SetWindowsHookEx(
WH_GETMESSAGE,
GetMessageProc,
AfxGetInstanceHandle(),
GetCurrentThreadId());
ASSERT (hHook);
.......
}
After that, the tooltips can show in the modeless dialog, but just a flash. when you dont move your mouse in the IDC_EDIT1, the tooltips can show no more than one second and disappear. you should move mouse back
to let the tooltips show a flash.
Continue reading...