Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Tooltip behind dialog

Tooltip behind dialog

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _Flaviu
    wrote on last edited by
    #1

    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 class

    switch(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 from CDialog ... what I have done wrong here ? Could you help me ? Thank you.

    J 1 Reply Last reply
    0
    • _ _Flaviu

      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 class

      switch(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 from CDialog ... what I have done wrong here ? Could you help me ? Thank you.

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      Has your dialog the top most status (e.g. by calling SetWindowPos with HWND_TOPMOST or setting the WS_EX_TOPMOST style)? Then change that.

      _ 2 Replies Last reply
      0
      • J Jochen Arndt

        Has your dialog the top most status (e.g. by calling SetWindowPos with HWND_TOPMOST or setting the WS_EX_TOPMOST style)? Then change that.

        _ Offline
        _ Offline
        _Flaviu
        wrote on last edited by
        #3

        The only call with SetWindowPos is

        SetWindowPos(
        	FindWindow(\_T("Shell\_TrayWnd"), \_T("")),
        	m\_nStartPosX, 
        	m\_nStartPosY, 
        	rc.Width(), 
        	rc.Height(),
        	SWP\_NOOWNERZORDER | SWP\_NOACTIVATE);
        

        inside of CAlertDialog ... I don't think this call is the issue ...

        1 Reply Last reply
        0
        • J Jochen Arndt

          Has your dialog the top most status (e.g. by calling SetWindowPos with HWND_TOPMOST or setting the WS_EX_TOPMOST style)? Then change that.

          _ Offline
          _ Offline
          _Flaviu
          wrote on last edited by
          #4

          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 !!!

          J 1 Reply Last reply
          0
          • _ _Flaviu

            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 !!!

            J Offline
            J Offline
            Jochen Arndt
            wrote on last edited by
            #5

            I was just going to suggest removing SWP_NOOWNERZORDER. However, fine to hear that it seems to be solved.

            _ 3 Replies Last reply
            0
            • J Jochen Arndt

              I was just going to suggest removing SWP_NOOWNERZORDER. However, fine to hear that it seems to be solved.

              _ Offline
              _ Offline
              _Flaviu
              wrote on last edited by
              #6

              Still, I will try your suggestion ... I'll come back.

              1 Reply Last reply
              0
              • J Jochen Arndt

                I was just going to suggest removing SWP_NOOWNERZORDER. However, fine to hear that it seems to be solved.

                _ Offline
                _ Offline
                _Flaviu
                wrote on last edited by
                #7

                Yep, I removed SWP_NOOWNERZORDER flag, and everything seem to be all right now, without m_ToolTip.SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE); ... so, it is better solution ! Thank you again ! :)

                1 Reply Last reply
                0
                • J Jochen Arndt

                  I was just going to suggest removing SWP_NOOWNERZORDER. However, fine to hear that it seems to be solved.

                  _ Offline
                  _ Offline
                  _Flaviu
                  wrote on last edited by
                  #8

                  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.

                  J 1 Reply Last reply
                  0
                  • _ _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.

                    J Offline
                    J Offline
                    Jochen Arndt
                    wrote on last edited by
                    #9

                    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.

                    _ 1 Reply Last reply
                    0
                    • J Jochen Arndt

                      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.

                      _ Offline
                      _ Offline
                      _Flaviu
                      wrote on last edited by
                      #10

                      Ok, I will. It is always a pleasure to talk with you. Thank you for sharing your experience !

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups