Results 1 to 11 of 11

Thread: tool tip text without form focus

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    tool tip text without form focus

    i have a small form and it just has a label control on it and i want without giving the form fucus to be able to have tool tip text or something like it when the mouse hovers over it without clicking. is this possible?

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    Re: tool tip text without form focus

    I do have a tooltip text for the label but since the form doesnt have focus it wont display

  4. #4
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: tool tip text without form focus

    Sean

    One possibility is to use MouseMove.

    The following code snippet is for a FlexGrid named fcLOG.
    I just tried it on a form that does not have focus, and it
    still triggers and calls the sub.

    On a form named vs2006
    Code:
    Private Sub fcLOG_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
        '
        bn77oVarsMouseSort x, y
        '
    End Sub
    In a module
    Code:
    Public Sub bn77oVarsMouseSort(nXX, nYY)
        '
        With vs2006
            With .fcLOG
                Select Case nYY
                    Case Is < 480
                        vs2006.pbF(0).Visible = False
                        vs2006.txtTIPver2.Visible = False
                    Case Is >= 480
                        ' >> code here to launch a TextBox to act as a ToolTip
                End Select
            End With
        End With
        '
    End Sub
    It may be more than you need ... modify to suit your situation.
    Hope it helps.

    EDIT: I added the module's code. You don't need to put it in a module,
    mine just happened to be in one.

    Spoo
    Last edited by Spoo; May 16th, 2011 at 09:18 PM.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    Re: tool tip text without form focus

    Spoo,

    thank you i got this to work


    Code:
    Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    
     With Form1
            With .Label1
                Select Case Y
                    Case Is < 600
                    MsgBox "Testing"
                    ' >> code here to launch a TextBox to act as a ToolTip
                        
                    
                End Select
            End With
        End With
        
    End Sub
    it will launch a msgbox but of course i need something more like a tooltip. what do you mean when you say launch a text box to act as a tooltip?

  6. #6
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: tool tip text without form focus

    Sean

    Hey, glad to hear it.

    Regarding "launch a textbox to act as a tooltip" .. sorry for the
    incomplete reference. I was referring to (in my case) vs2006.txtTIPver2

    It is a TextBox control I manually added to the form ...
    • Visible = False
    • BackColor = light yellow - in the Properties window it reads
      &H00C0FFFF& which is equivalent to RGB(255, 255,150)
    • Height = 285
    • Width = 975
    • Top = 6960
    • Left = 1320
    • MultiLine = True

    I then had code in the Case Is >= 480 branch to reconfigure and
    populate the TextBox as needed. The code also repositioned it relative
    to the Top, Left, and Width of the FG.

    Keep in mind that the MouseMove event returns coordinates relative to
    the control in question (me - FlexGrid, you - Label), as opposed to
    the Form.

    I wanted there to be a zone within the FG that would be "hot" -- ie, show
    the tooltip. Thus, if nYY < 480, the tooltip would turn off, otherwise it
    would be visible. This is rather tight. Sometimes, if I moved the mouse
    too rapidly, the tooltip would not get turned off. So, as a backup, I
    also had a MouseMove event on the Form itself to turn off the tooltip.

    I hope that explains things a little more clearly.

    Spoo
    Last edited by Spoo; May 17th, 2011 at 09:07 AM. Reason: added Top and Left positioning comments

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    Re: tool tip text without form focus

    Spoo,

    your concept is very cleaver. the pop up text box would work well for me except for my app is a little button that floats on thop of all other windows. i made it for a panic button at my work. so since its really small the popup text box wouldnt work. so using the first part of your code im half way there. i just need to figure out something to pop up now. any ideas?

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: tool tip text without form focus

    You only have two choices really...a form or a message box.

    You can make the form borderless and very, very small. You can set a timer on it so it will unload itself.

  9. #9
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: tool tip text without form focus

    Sean

    Given the additional info you've provided, it seems that Hack's two
    alternatives remain your best bet.

    A question, though.. if your Form is basically a Button, what sort of info
    would the ToolTip provide? That is, what are you trying to accomplish?
    Perhaps if you could attach a screen-grab, we could get a better sense
    of things.

    Spoo

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    259

    Re: tool tip text without form focus

    the little form should work fine. i will work on that tonight.

    the application is a panic button app that starts up with the pc and is movable and when double clicked it creates a record that will pop up an alert on teh security guards pc that there is a security alert. the app works great but i want a type of tooltip text to notify any new users on our computer to exactly what this thing is on there screen. it doesnt look like any other window because its round and is always on top. and the size of a quarter on their screen. this is a hospital so we have all different type of users

  11. #11
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: tool tip text without form focus

    With form's being out of focus mouse_move won't work at all.
    In addition to Hack's suggestion (small form) you will need few api:
    - GetCursorPos (to get presize position of your cursor on the screen); POINAPI type will need to be defined (x,y)
    - GetWindowRect (to get your form's window rectangle adjusted to include label position+size); you will also need to define RECT type (left, top, right, width)

    On timer event (interval can be as little as 10-20) you will need to get current cursor postion and then check whether or not it is within your defined rectangle.
    If it is then show your own tooltip form.

    I believe I have very similar sample(s) already posted so try searching through my posts (either of those api should bring back results).



    ps, best way over all would be to subclass one of "move" messages but that is also much complicated approach.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width