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. Displaying a ToolTip

Displaying a ToolTip

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 3 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.
  • A Offline
    A Offline
    ajitatif angajetor
    wrote on last edited by
    #1

    Hi everyone, I'm trying to add a tooltip to my buttons on a toolbar,but without any luck.I checked it out with spy++ and HWND seems valid,but i can't activate the tool tip.According to documentation stuff,I do not have to write a message handler for my tooltips to be displayed (I use the TTF_SUBCLASS flag),am I wrong,or missing something in the code below? RECT rect; HWND hwndTT; INITCOMMONCONTROLSEX iccex; ATLVERIFY((SendMessage(hwndParent,TB_GETITEMRECT,(WPARAM) iButton,(LPARAM) (LPRECT)&rect)) == TRUE); // get button rectangle,working OK. iccex.dwICC = ICC_WIN95_CLASSES; iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCommonControlsEx(&iccex); if ((hwndTT = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndParent, NULL, NULL, NULL )) == NULL) return NULL; ::SetWindowPos(hwndTT,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); TOOLINFO ti; ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS; ti.hwnd = hwndParent; ti.lpszText = (LPTSTR) lpszText; ti.rect.bottom = rect.bottom; ti.rect.left = rect.left; ti.rect.top = rect.top; ti.rect.right = rect.right; SendMessage(hwndTT,TTM_SETDELAYTIME,TTDT_INITIAL,0L); return SendMessage(hwndTT,TTM_ADDTOOL,0,(LPARAM)&ti);

    T P 2 Replies Last reply
    0
    • A ajitatif angajetor

      Hi everyone, I'm trying to add a tooltip to my buttons on a toolbar,but without any luck.I checked it out with spy++ and HWND seems valid,but i can't activate the tool tip.According to documentation stuff,I do not have to write a message handler for my tooltips to be displayed (I use the TTF_SUBCLASS flag),am I wrong,or missing something in the code below? RECT rect; HWND hwndTT; INITCOMMONCONTROLSEX iccex; ATLVERIFY((SendMessage(hwndParent,TB_GETITEMRECT,(WPARAM) iButton,(LPARAM) (LPRECT)&rect)) == TRUE); // get button rectangle,working OK. iccex.dwICC = ICC_WIN95_CLASSES; iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCommonControlsEx(&iccex); if ((hwndTT = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndParent, NULL, NULL, NULL )) == NULL) return NULL; ::SetWindowPos(hwndTT,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); TOOLINFO ti; ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS; ti.hwnd = hwndParent; ti.lpszText = (LPTSTR) lpszText; ti.rect.bottom = rect.bottom; ti.rect.left = rect.left; ti.rect.top = rect.top; ti.rect.right = rect.right; SendMessage(hwndTT,TTM_SETDELAYTIME,TTDT_INITIAL,0L); return SendMessage(hwndTT,TTM_ADDTOOL,0,(LPARAM)&ti);

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      please when posting a piece of code, to use the <pre> tag instead of the <code> one. thanks


      Don't know where to start ?
      Refer the Forums Guidelines and ask a friend

      [VisualCalc 3.0][Flags Beginner's Guide]

      1 Reply Last reply
      0
      • A ajitatif angajetor

        Hi everyone, I'm trying to add a tooltip to my buttons on a toolbar,but without any luck.I checked it out with spy++ and HWND seems valid,but i can't activate the tool tip.According to documentation stuff,I do not have to write a message handler for my tooltips to be displayed (I use the TTF_SUBCLASS flag),am I wrong,or missing something in the code below? RECT rect; HWND hwndTT; INITCOMMONCONTROLSEX iccex; ATLVERIFY((SendMessage(hwndParent,TB_GETITEMRECT,(WPARAM) iButton,(LPARAM) (LPRECT)&rect)) == TRUE); // get button rectangle,working OK. iccex.dwICC = ICC_WIN95_CLASSES; iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCommonControlsEx(&iccex); if ((hwndTT = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndParent, NULL, NULL, NULL )) == NULL) return NULL; ::SetWindowPos(hwndTT,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); TOOLINFO ti; ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS; ti.hwnd = hwndParent; ti.lpszText = (LPTSTR) lpszText; ti.rect.bottom = rect.bottom; ti.rect.left = rect.left; ti.rect.top = rect.top; ti.rect.right = rect.right; SendMessage(hwndTT,TTM_SETDELAYTIME,TTDT_INITIAL,0L); return SendMessage(hwndTT,TTM_ADDTOOL,0,(LPARAM)&ti);

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

        ajitatif angajetor wrote:

        SendMessage(hwndTT,TTM_SETDELAYTIME,TTDT_INITIAL,0L);

        You have passed delay time value(LPARAM) as 0. Is it intentional ? For setting default delay it should be -1.

        Prasad Notifier using ATL | Operator new[],delete[][^]

        A 1 Reply Last reply
        0
        • P prasad_som

          ajitatif angajetor wrote:

          SendMessage(hwndTT,TTM_SETDELAYTIME,TTDT_INITIAL,0L);

          You have passed delay time value(LPARAM) as 0. Is it intentional ? For setting default delay it should be -1.

          Prasad Notifier using ATL | Operator new[],delete[][^]

          A Offline
          A Offline
          ajitatif angajetor
          wrote on last edited by
          #4

          prasad_som wrote:

          You have passed delay time value(LPARAM) as 0. Is it intentional ?

          Yes,to pop the ToolTip up instantly,so I can see the rectangle is exactly as I meant it to be.

          P 1 Reply Last reply
          0
          • A ajitatif angajetor

            prasad_som wrote:

            You have passed delay time value(LPARAM) as 0. Is it intentional ?

            Yes,to pop the ToolTip up instantly,so I can see the rectangle is exactly as I meant it to be.

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

            Code is looking ok to me. Can you show how you have created toolbar ?

            Prasad Notifier using ATL | Operator new[],delete[][^]

            A 1 Reply Last reply
            0
            • P prasad_som

              Code is looking ok to me. Can you show how you have created toolbar ?

              Prasad Notifier using ATL | Operator new[],delete[][^]

              A Offline
              A Offline
              ajitatif angajetor
              wrote on last edited by
              #6

              uh,i had to hack my code much more throughly to see it was all about rectangles.i found out that the toolbar had one of the items resized after i created the tooltip (with the wrong rectangles). and i added a TB_SETTOOLTIPS message right after the TTM_ADDTOOL.works just fine now,thanks for everything :)

              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