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. Problem in displaying tooltip

Problem in displaying tooltip

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

    Hi, I want to display a tooltip over a propertysheet whenever user will put the mouse cusor on its left or right border. I am using the following code

    LRESULT MySubCard::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
    {
    LRESULT result = 0;

    try
    {
    	switch (message)
    	{
    		case WM\_LBUTTONDOWN:
    		case WM\_RBUTTONDOWN:
    		case WM\_MBUTTONDOWN:
    		case WM\_LBUTTONUP:
    		case WM\_RBUTTONUP:
    		case WM\_MBUTTONUP:
    		case WM\_MOUSEMOVE:
    		{
    			// Mouse messages must be relayed to tooltip control
    			if (::IsWindow(mLeftToolTip.GetSafeHwnd()))
    			{
    				MSG msg;
    				msg.hwnd = m\_hWnd;
    				msg.message = message;
    				msg.wParam = wParam;
    				msg.lParam = lParam;
    
    				if(Within left or rigth border)
    				{
    				   mLeftToolTip.Activate(TRUE);
    				   mLeftToolTip.RelayEvent(&msg);
    				}
    			}
    		}
    
    		default:
    		{
    			break;
    		}
    	}
    	result = CWnd::WindowProc(message, wParam, lParam);
    }
    catch (...) 
    {
    }    
    
    return result;
    

    }

    I am setting the tool using the following code

    mLeftToolTip.AddTool(this, szToolTip, borderarea, ID_SPLITTER_TOOLTIP);

    Though in windowproc RelayEvent is getting called for mouse movements but the tooltip is not getting displayed. Thanks

    C 1 Reply Last reply
    0
    • A ashtwin

      Hi, I want to display a tooltip over a propertysheet whenever user will put the mouse cusor on its left or right border. I am using the following code

      LRESULT MySubCard::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
      {
      LRESULT result = 0;

      try
      {
      	switch (message)
      	{
      		case WM\_LBUTTONDOWN:
      		case WM\_RBUTTONDOWN:
      		case WM\_MBUTTONDOWN:
      		case WM\_LBUTTONUP:
      		case WM\_RBUTTONUP:
      		case WM\_MBUTTONUP:
      		case WM\_MOUSEMOVE:
      		{
      			// Mouse messages must be relayed to tooltip control
      			if (::IsWindow(mLeftToolTip.GetSafeHwnd()))
      			{
      				MSG msg;
      				msg.hwnd = m\_hWnd;
      				msg.message = message;
      				msg.wParam = wParam;
      				msg.lParam = lParam;
      
      				if(Within left or rigth border)
      				{
      				   mLeftToolTip.Activate(TRUE);
      				   mLeftToolTip.RelayEvent(&msg);
      				}
      			}
      		}
      
      		default:
      		{
      			break;
      		}
      	}
      	result = CWnd::WindowProc(message, wParam, lParam);
      }
      catch (...) 
      {
      }    
      
      return result;
      

      }

      I am setting the tool using the following code

      mLeftToolTip.AddTool(this, szToolTip, borderarea, ID_SPLITTER_TOOLTIP);

      Though in windowproc RelayEvent is getting called for mouse movements but the tooltip is not getting displayed. Thanks

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      When you move the mouse on the border of a window you get WM_NCMOUSEMOVE[^] and friends, not WM_MOUSEMOVE and his buddies. Althorough i doubt the tooltip control would react on these...maybe you could try "transforming" the non-client messages to client-messages when relaying to the tooltip.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

      A 1 Reply Last reply
      0
      • C Code o mat

        When you move the mouse on the border of a window you get WM_NCMOUSEMOVE[^] and friends, not WM_MOUSEMOVE and his buddies. Althorough i doubt the tooltip control would react on these...maybe you could try "transforming" the non-client messages to client-messages when relaying to the tooltip.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

        A Offline
        A Offline
        ashtwin
        wrote on last edited by
        #3

        Hi, thanks for replaying. I tried NC messages also but they are also not working. My doubt is that whether we can display tooltip for a region in a dialog or not. Thanks

        C 1 Reply Last reply
        0
        • A ashtwin

          Hi, thanks for replaying. I tried NC messages also but they are also not working. My doubt is that whether we can display tooltip for a region in a dialog or not. Thanks

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          Am not completely sure but it should work since as far as i know the dialog, from the perspecfive of the tooltip is just a CWnd like any other... How did you create the region you specified for it, what coords did you use? I think what you could do is to somehow calculate the border area's position in client coordinates and add these to the tooltip. Then, when WM_NCMOUSEMOVE comes in, convert the mouse coords to client coords of the window, and feed these to the tooltip with WM_MOUSEMOVE instead of WM_NCMOUSEMOVE. No idea if this would work or not, but it might be worth a try. So i mean something like this:

          ...
          case WM_NCMOUSEMOVE:
          {
          CPoint Pt(lParam);
          ScreenToClient(Pt);

          MSG msg;
          msg.hwnd = m_hWnd;
          msg.message = WM_MOUSEMOVE;
          msg.wParam = wParam;
          msg.lParam = MAKELPARAM(Pt.x, Pt.y);
          mLeftToolTip.RelayEvent(&msg);
          }
          ...

          [edit] Hey, i just tryed it out, you don't need all this fancypants "message converting" thing, if you feed the tooltip the coordinates of the borders in client-space then it will work flawlessly.

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

          modified on Wednesday, February 25, 2009 8:34 AM

          A 1 Reply Last reply
          0
          • C Code o mat

            Am not completely sure but it should work since as far as i know the dialog, from the perspecfive of the tooltip is just a CWnd like any other... How did you create the region you specified for it, what coords did you use? I think what you could do is to somehow calculate the border area's position in client coordinates and add these to the tooltip. Then, when WM_NCMOUSEMOVE comes in, convert the mouse coords to client coords of the window, and feed these to the tooltip with WM_MOUSEMOVE instead of WM_NCMOUSEMOVE. No idea if this would work or not, but it might be worth a try. So i mean something like this:

            ...
            case WM_NCMOUSEMOVE:
            {
            CPoint Pt(lParam);
            ScreenToClient(Pt);

            MSG msg;
            msg.hwnd = m_hWnd;
            msg.message = WM_MOUSEMOVE;
            msg.wParam = wParam;
            msg.lParam = MAKELPARAM(Pt.x, Pt.y);
            mLeftToolTip.RelayEvent(&msg);
            }
            ...

            [edit] Hey, i just tryed it out, you don't need all this fancypants "message converting" thing, if you feed the tooltip the coordinates of the borders in client-space then it will work flawlessly.

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

            modified on Wednesday, February 25, 2009 8:34 AM

            A Offline
            A Offline
            ashtwin
            wrote on last edited by
            #5

            Hi, Its working. Thanks a lot.:-)

            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