Tooltip behind dialog
-
Which could be the reason why a tooltip is layered behind the dialog ? Here is the implementation:
class CNotifyDlg : public CAlertDialog
{
CToolTipCtrl m_ToolTip;
}and
BOOL CNotifyDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base classswitch(pMsg->message) { case WM\_LBUTTONDOWN: case WM\_LBUTTONUP: case WM\_MOUSEMOVE: m\_ToolTip.RelayEvent(pMsg); } return CAlertDialog::PreTranslateMessage(pMsg);
}
BOOL CNotifyDlg::OnInitDialog()
{
CAlertDialog::OnInitDialog();m\_ToolTip.Create(this); m\_ToolTip.AddTool(GetDlgItem(IDCANCEL), \_T("My message")); m\_ToolTip.Activate(TRUE); return TRUE;
}
LRESULT CNotifyDlg::OnButtonMouseOver(WPARAM wParam, LPARAM lParam)
{
if(m_btnClose.GetDlgCtrlID() == (int)wParam)
m_ToolTip.UpdateTipText(_T("My message again"), GetDlgItem(IDCANCEL));
m_ToolTip.Update();return 0;
}
and I see the tooltip window, but is just behind the dialog ... I can not figure out why is happen this ...
CAlertDialog
is derived fromCDialog
... what I have done wrong here ? Could you help me ? Thank you. -
Which could be the reason why a tooltip is layered behind the dialog ? Here is the implementation:
class CNotifyDlg : public CAlertDialog
{
CToolTipCtrl m_ToolTip;
}and
BOOL CNotifyDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base classswitch(pMsg->message) { case WM\_LBUTTONDOWN: case WM\_LBUTTONUP: case WM\_MOUSEMOVE: m\_ToolTip.RelayEvent(pMsg); } return CAlertDialog::PreTranslateMessage(pMsg);
}
BOOL CNotifyDlg::OnInitDialog()
{
CAlertDialog::OnInitDialog();m\_ToolTip.Create(this); m\_ToolTip.AddTool(GetDlgItem(IDCANCEL), \_T("My message")); m\_ToolTip.Activate(TRUE); return TRUE;
}
LRESULT CNotifyDlg::OnButtonMouseOver(WPARAM wParam, LPARAM lParam)
{
if(m_btnClose.GetDlgCtrlID() == (int)wParam)
m_ToolTip.UpdateTipText(_T("My message again"), GetDlgItem(IDCANCEL));
m_ToolTip.Update();return 0;
}
and I see the tooltip window, but is just behind the dialog ... I can not figure out why is happen this ...
CAlertDialog
is derived fromCDialog
... what I have done wrong here ? Could you help me ? Thank you.Has your dialog the top most status (e.g. by calling
SetWindowPos
withHWND_TOPMOST
or setting theWS_EX_TOPMOST
style)? Then change that. -
Has your dialog the top most status (e.g. by calling
SetWindowPos
withHWND_TOPMOST
or setting theWS_EX_TOPMOST
style)? Then change that. -
Has your dialog the top most status (e.g. by calling
SetWindowPos
withHWND_TOPMOST
or setting theWS_EX_TOPMOST
style)? Then change that.But you gave an idea:
m\_ToolTip.Create(this, TTS\_ALWAYSTIP | TTS\_NOPREFIX); m\_ToolTip.AddTool(GetDlgItem(IDCANCEL), \_T("Bla bla bla")); m\_ToolTip.Activate(TRUE); m\_ToolTip.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP\_NOSIZE);
I don't know if it's all right, but seem to work ... :) Thank you !!!
-
But you gave an idea:
m\_ToolTip.Create(this, TTS\_ALWAYSTIP | TTS\_NOPREFIX); m\_ToolTip.AddTool(GetDlgItem(IDCANCEL), \_T("Bla bla bla")); m\_ToolTip.Activate(TRUE); m\_ToolTip.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP\_NOSIZE);
I don't know if it's all right, but seem to work ... :) Thank you !!!
I was just going to suggest removing
SWP_NOOWNERZORDER
. However, fine to hear that it seems to be solved. -
I was just going to suggest removing
SWP_NOOWNERZORDER
. However, fine to hear that it seems to be solved. -
I was just going to suggest removing
SWP_NOOWNERZORDER
. However, fine to hear that it seems to be solved. -
I was just going to suggest removing
SWP_NOOWNERZORDER
. However, fine to hear that it seems to be solved.Hi Johen. After all, I can not give up SWP_NOOWNERZORDER flag ... It should be there, but I want to ask you what is the best solution to put tooltip above CDialog which has SWP_NOOWNERZORDER flag:
SetWindowPos(
FindWindow(_T("Shell_TrayWnd"), _T("")),
m_nStartPosX,
m_nStartPosY,
rc.Width(),
rc.Height(),
SWP_NOOWNERZORDER | SWP_NOACTIVATE);the solution was the following:
BOOL CNotifyDlg::OnInitDialog()
{
CAlertDialog::OnInitDialog();m_ToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);
m_ToolTip.AddTool(GetDlgItem(IDCANCEL), _T("Close this notification"));
m_ToolTip.Activate(TRUE);
m_ToolTip.SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOOWNERZORDER | SWP_NOSIZE);return TRUE;
}It is ok ? To be frank, I don't like idea to setup tooltip as top level window ... there is another solution ? Flaviu.
-
Hi Johen. After all, I can not give up SWP_NOOWNERZORDER flag ... It should be there, but I want to ask you what is the best solution to put tooltip above CDialog which has SWP_NOOWNERZORDER flag:
SetWindowPos(
FindWindow(_T("Shell_TrayWnd"), _T("")),
m_nStartPosX,
m_nStartPosY,
rc.Width(),
rc.Height(),
SWP_NOOWNERZORDER | SWP_NOACTIVATE);the solution was the following:
BOOL CNotifyDlg::OnInitDialog()
{
CAlertDialog::OnInitDialog();m_ToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);
m_ToolTip.AddTool(GetDlgItem(IDCANCEL), _T("Close this notification"));
m_ToolTip.Activate(TRUE);
m_ToolTip.SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOOWNERZORDER | SWP_NOSIZE);return TRUE;
}It is ok ? To be frank, I don't like idea to setup tooltip as top level window ... there is another solution ? Flaviu.
A tooltip should be a top level window to ensure that it is visible. It is only shown when requested by the user and closed when clicking anywhere with the mouse. So it does not interfere with other GUI elements. If you have a working solution I would stay with that.
-
A tooltip should be a top level window to ensure that it is visible. It is only shown when requested by the user and closed when clicking anywhere with the mouse. So it does not interfere with other GUI elements. If you have a working solution I would stay with that.