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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ToolTip is not Shown

ToolTip is not Shown

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
7 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.
  • P Offline
    P Offline
    poda
    wrote on last edited by
    #1

    I have problem in displaying the tooltip. In the header file of the Dialog,I declare the message handler as afx_msg BOOL ShowMyToolTips(UINT id, NMHDR* pTTTStruct, LRESULT* pResult); In the .cpp file of the Dialog, BEGIN_MESSAGE_MAP(CSimpleToolTipDlg, CDialog) ... ON_NOTIFY_EX(TTN_NEEDTEXT,0,ShowMyToolTips) END_MESSAGE_MAP() In the OnInitDialog BOOL CSimpleToolTipDlg::OnInitDialog() { ... EnableToolTips(true);//This is required return TRUE; } Then the definition of the message handler BOOL CSimpleToolTipDlg::ShowMyToolTips(UINT id, NMHDR* pNMHDR, LRESULT* pResult) { TOOLTIPTEXT *pTTT = (TOOLTIPTEXT*)pNMHDR; UINT nID = pNMHDR->idFrom; if(pTTT->uFlags & TTF_IDISHWND) { // idFrom is actually the HWND of the tool nID = ::GetDlgCtrlID((HWND)nID); if(nID) { pTTT->lpszText = "I am a ToolTip";//MAKEINTRESOURCE(nID); pTTT->hinst = AfxGetResourceHandle(); return(TRUE); } } return(FALSE); } The big problem is,ShowMyToolTips() function is not called at all. I even tried ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, ShowMyToolTips) ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, ShowMyToolTips) But it also does not work. Do any one know what's wrong.

    N 1 Reply Last reply
    0
    • P poda

      I have problem in displaying the tooltip. In the header file of the Dialog,I declare the message handler as afx_msg BOOL ShowMyToolTips(UINT id, NMHDR* pTTTStruct, LRESULT* pResult); In the .cpp file of the Dialog, BEGIN_MESSAGE_MAP(CSimpleToolTipDlg, CDialog) ... ON_NOTIFY_EX(TTN_NEEDTEXT,0,ShowMyToolTips) END_MESSAGE_MAP() In the OnInitDialog BOOL CSimpleToolTipDlg::OnInitDialog() { ... EnableToolTips(true);//This is required return TRUE; } Then the definition of the message handler BOOL CSimpleToolTipDlg::ShowMyToolTips(UINT id, NMHDR* pNMHDR, LRESULT* pResult) { TOOLTIPTEXT *pTTT = (TOOLTIPTEXT*)pNMHDR; UINT nID = pNMHDR->idFrom; if(pTTT->uFlags & TTF_IDISHWND) { // idFrom is actually the HWND of the tool nID = ::GetDlgCtrlID((HWND)nID); if(nID) { pTTT->lpszText = "I am a ToolTip";//MAKEINTRESOURCE(nID); pTTT->hinst = AfxGetResourceHandle(); return(TRUE); } } return(FALSE); } The big problem is,ShowMyToolTips() function is not called at all. I even tried ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, ShowMyToolTips) ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, ShowMyToolTips) But it also does not work. Do any one know what's wrong.

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      overide the OnNotify function and inside it check for the code TTN_NEEDTEXT

      nave

      P 1 Reply Last reply
      0
      • N Naveen

        overide the OnNotify function and inside it check for the code TTN_NEEDTEXT

        nave

        P Offline
        P Offline
        poda
        wrote on last edited by
        #3

        You are great man! It works fine,if I just override OnNotify function without adding any code in it. If you know the reason why it does not work if OnNotify was not overridden,let me also know that. Thank you so much.

        N 1 Reply Last reply
        0
        • P poda

          You are great man! It works fine,if I just override OnNotify function without adding any code in it. If you know the reason why it does not work if OnNotify was not overridden,let me also know that. Thank you so much.

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #4

          poda123 wrote:

          I just override OnNotify

          u didn't write any code inside it?:confused:

          nave

          P 1 Reply Last reply
          0
          • N Naveen

            poda123 wrote:

            I just override OnNotify

            u didn't write any code inside it?:confused:

            nave

            P Offline
            P Offline
            poda
            wrote on last edited by
            #5

            Yes, I did not write any code in OnNotify().But it works. Also I cannot write the code of TTN_NEEDTEXT message handler's code in OnNotify() function because the parameters has to be given by the OS BOOL CWFPDlg::ShowMyToolTips(UINT id, NMHDR* pNMHDR, LRESULT* pResult) { }

            N 1 Reply Last reply
            0
            • P poda

              Yes, I did not write any code in OnNotify().But it works. Also I cannot write the code of TTN_NEEDTEXT message handler's code in OnNotify() function because the parameters has to be given by the OS BOOL CWFPDlg::ShowMyToolTips(UINT id, NMHDR* pNMHDR, LRESULT* pResult) { }

              N Offline
              N Offline
              Naveen
              wrote on last edited by
              #6

              u can d like this. BOOL CWFPDlg::ShowMyToolTips(UINT id, NMHDR* pNMHDR, LRESULT* pResult) { if( pNMHDR->code == TTN_NEEDTEXT) { // u r code... } } any way now it working na.. where r u from?

              nave

              P 1 Reply Last reply
              0
              • N Naveen

                u can d like this. BOOL CWFPDlg::ShowMyToolTips(UINT id, NMHDR* pNMHDR, LRESULT* pResult) { if( pNMHDR->code == TTN_NEEDTEXT) { // u r code... } } any way now it working na.. where r u from?

                nave

                P Offline
                P Offline
                poda
                wrote on last edited by
                #7

                You suggested me to write the ShowMyToolTips() function code in OnNotify() function. Since the parameters such as NMDHR* has to be given by OS,I cannot write it in overridden OnNotify() function. ShowMyToolTips() function is the Message Handler for the Message TTN_NEEDTEXT. So again why should I check like if( pNMHDR->code == TTN_NEEDTEXT) { // u r code... } Thanks for your reply. I am from Chennai,India.

                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