Results 1 to 5 of 5

Thread: Mousemove Event - How to show "bubble" textboxes

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Location
    Houston, TX - USA
    Posts
    21

    Post

    VB6 does not have a "onMouseEnter" and a "OnMouseExit" event, just the "MouseMove".

    If I want to display a hidden TextBox as a consequence of an user moving his/hers mouse cursor over a CommandButton (without clicking), using the MouseMove event causes the Textbox to be displayed, which is what we can expect.

    However, moving the cursor out of the borders of that CommandButton DOES NOT cause the Textbox to hide again, and it keeps there displayed.

    Perhaps we could use a Timer to set how long the textbox remains displayed, but if the text in the box is (for example) 10 lines long, then it would be annoying to the user.

    I believe VB6 does not have a "OnMouseEnter" and a "OnMouseExit" events, which are part of the JavaScript Specification, among others. Is that true?

    I also know that a "ToolTip" could be an alternative, but it requires the Timer, which brings us back to the beginning.

    Can anybody help??

    ------------------
    Paul Stermann
    DSI-Houston

    [This message has been edited by prestodsi (edited 11-01-1999).]

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Location
    Houston, TX - USA
    Posts
    21

    Post

    Dear DPearce:

    I found a different solution which will require some coding. I tested it and it works fine. I will post my code here tomorrow
    Thank you

    ------------------
    Paul Stermann
    DSI-Houston

  3. #3
    New Member
    Join Date
    Aug 1999
    Location
    Bucks
    Posts
    12

    Post

    THe only way I can think of is to check the mousemove property of all the other objects on the form(and the form itself) and hide your textbox when this happens. (You may need a timer event in there for safety in case someone wisks the mouse right off the app before it detects it.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Location
    Houston, TX - USA
    Posts
    21

    Post

    The solution I found passes through finding the mouse coordinates (its x.y location)in the form at which your bubble needs to be displayed.

    To make it easier, go to:
    "http://www.vb-world.net/mouse/tip65.html",
    and study Steve Anderson's code and example.
    Print it.

    Then,

    1- Create and standard VB6 application and place the Timer (Interval = 1) and 2 Labels (caption = Empty)
    2- Follow Anderson's instructions to set your modules and your code right
    3- Run (F5) and see how the labels display the mouse pointer coordinates
    4- Create a CommandButton and a TextBox. Make the textBox.visible = false and
    textbox.name = txtMainBubble, for example.

    5- Run the application again and take note of the mouse x & y coordinates at the top-left and bottom-right edges of the CommandButton. Write them down somewhere!

    6- Then write the following code (see that I have ammended Anderson's code:

    Option Explicit
    ' DECLARE VARIABLE. POINTAPI IS AT MODULE LEVEL

    Dim z As POINTAPI
    Dim Wrap$
    _________________________________
    Private Sub Timer1_Timer()
    Dim MyBubbleWords
    'ATTRIBUTE BUBBLE TEXT
    MyBubbleWords = "bla" + Wrap$ + "bla"

    'CALL PROCEDURE
    ' GET COORDINATES. FUNCTION IS AT MODULE LEVEL

    GetCursorPos z
    Label1 = "x: " & z.x 'GET X COORDINATE
    Label2 = "y: " & z.y 'GET Y COORDINATE
    Wrap$ = Chr(13) + Chr(10)
    If z.x >= 269 And z.x <= 507 And z.y >= 116 And z.y <= 146 Then
    txtMainBubble.Visible = True
    txtMainBubble.Text = MyBubbleWords
    'RELEASE VARIABLE & HIDE BUBBLE
    Else
    txtMainBubble.Text = ""
    txtMainBubble.Visible = False
    End If
    End Sub
    _____________________
    See that z.x and z.y are my own values for the edges of my CommandButton. Use your own values.

    If you have more than one commandbutton, then find their edge coordinates and use the If ...Then ...Elseif ...End if statement to display different texts in the textbox.

    define MyBubbleWords1, MyBubbleWords2,... etc.

    It works fine and could be used pretty much with anything in you form, including pictures, etc, because it deals with the mouse position and nothing else


    ----------------
    Paul Stermann
    DSI-Houston

    [This message has been edited by prestodsi (edited 11-02-1999).]

    [This message has been edited by prestodsi (edited 11-02-1999).]

    [This message has been edited by prestodsi (edited 11-02-1999).]

    [This message has been edited by prestodsi (edited 11-02-1999).]

  5. #5
    Lively Member
    Join Date
    Sep 2001
    Location
    Western North Carolina
    Posts
    124
    You can use the mousemove event to do this....

    Say your command button is in a frame.

    'when mouse moves over command button make hidden text box
    'appear

    Private Sub cmdCancel_MouseMove(Button As Integer, Shift _
    As Integer, X As Single, Y As Single)

    txtHidden.Visible = True

    End Sub

    Then when the user moves the cursor off the command button and back onto the frame, make the text box hidden again

    'when mouse pointer moves over frame then make the hidden 'text box invisible
    Private Sub fraError_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    txtHidden.Visible = False

    End Sub


    This is the easiest way to do this that I have found. To make it more pleasant you could set up a couple of Sub Routines to store your code in, in case you want to hide or show multiple objects.

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