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#
  4. show tooltip even if treeview doesn't have focus?

show tooltip even if treeview doesn't have focus?

Scheduled Pinned Locked Moved C#
visual-studiocsharpquestion
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.
  • F Offline
    F Offline
    FocusedWolf
    wrote on last edited by
    #1

    I'm making a vs.net addin which has a custom treeview, in a custom toolwindow. I'm trying to replicate some of the basic features of the solution-explorer treeview but i have come across a snag when trying to show a tooltip for a partially visible treenode, when my treeview control doesn't have focus. Basically ToolTip.Show(...) fails to show a tooltip when my treeview isn't focused. vs.net can surprisingly do this in its solution-explorer treeview so long as vs.net has focus... it's treeview doesn't need focus. You can be typing away in the ide and mouse hover over a half visible file in the solution explorer and see its tooltip. I want that functionality for my treeview :P

    M 1 Reply Last reply
    0
    • F FocusedWolf

      I'm making a vs.net addin which has a custom treeview, in a custom toolwindow. I'm trying to replicate some of the basic features of the solution-explorer treeview but i have come across a snag when trying to show a tooltip for a partially visible treenode, when my treeview control doesn't have focus. Basically ToolTip.Show(...) fails to show a tooltip when my treeview isn't focused. vs.net can surprisingly do this in its solution-explorer treeview so long as vs.net has focus... it's treeview doesn't need focus. You can be typing away in the ide and mouse hover over a half visible file in the solution explorer and see its tooltip. I want that functionality for my treeview :P

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Can you trap the mouseover event on the node (does the node have a mouseover event) even if the control is not selected? Then handle the tooltip manually. If the node does not then use the treeview and hittest. Still it will be a lot of faffing about to get a tooltip.

      Never underestimate the power of human stupidity RAH

      F 1 Reply Last reply
      0
      • M Mycroft Holmes

        Can you trap the mouseover event on the node (does the node have a mouseover event) even if the control is not selected? Then handle the tooltip manually. If the node does not then use the treeview and hittest. Still it will be a lot of faffing about to get a tooltip.

        Never underestimate the power of human stupidity RAH

        F Offline
        F Offline
        FocusedWolf
        wrote on last edited by
        #3

        yes in my derived treeview i override OnMouseMove and this code does seem to execute even if the control isnt focused... atleast the breakpoint fires when i slide the mouse over the non-focused control. It's just the call to toolTip.Show(...) which fails to display a tooltip when the control has no focus. hmm. ok i checked out the Tooltip class with reflector and i see the problem. "IsWindowActive"... microsoft explicitly checks for being "active" before allowing a tooltip to show... i'll do more digging to see if their's an acceptable alternative to being focused. //from .net framework ToolTip class public void Show(string text, IWin32Window window, int x, int y) { if (window == null) { throw new ArgumentNullException("window"); } if (this.HasAllWindowsPermission && this.IsWindowActive(window)) { NativeMethods.RECT rect = new NativeMethods.RECT(); UnsafeNativeMethods.GetWindowRect(new HandleRef(window, Control.GetSafeHandle(window)), ref rect); int pointX = rect.left + x; int pointY = rect.top + y; this.SetTrackPosition(pointX, pointY); this.SetTool(window, text, TipInfo.Type.Absolute, new Point(pointX, pointY)); } }

        M 1 Reply Last reply
        0
        • F FocusedWolf

          yes in my derived treeview i override OnMouseMove and this code does seem to execute even if the control isnt focused... atleast the breakpoint fires when i slide the mouse over the non-focused control. It's just the call to toolTip.Show(...) which fails to display a tooltip when the control has no focus. hmm. ok i checked out the Tooltip class with reflector and i see the problem. "IsWindowActive"... microsoft explicitly checks for being "active" before allowing a tooltip to show... i'll do more digging to see if their's an acceptable alternative to being focused. //from .net framework ToolTip class public void Show(string text, IWin32Window window, int x, int y) { if (window == null) { throw new ArgumentNullException("window"); } if (this.HasAllWindowsPermission && this.IsWindowActive(window)) { NativeMethods.RECT rect = new NativeMethods.RECT(); UnsafeNativeMethods.GetWindowRect(new HandleRef(window, Control.GetSafeHandle(window)), ref rect); int pointX = rect.left + x; int pointY = rect.top + y; this.SetTrackPosition(pointX, pointY); this.SetTool(window, text, TipInfo.Type.Absolute, new Point(pointX, pointY)); } }

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Then you'll find there is something buried under NativeMethods.RECT that needs addressing, 2 weeks from now you will be pushing 1s and 0s at the hardware :laugh: .

          Never underestimate the power of human stupidity RAH

          F 1 Reply Last reply
          0
          • M Mycroft Holmes

            Then you'll find there is something buried under NativeMethods.RECT that needs addressing, 2 weeks from now you will be pushing 1s and 0s at the hardware :laugh: .

            Never underestimate the power of human stupidity RAH

            F Offline
            F Offline
            FocusedWolf
            wrote on last edited by
            #5

            ya... i could decompile tooltip... recompile without the offending check... or i can just let this one slide lol

            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