Results 1 to 7 of 7

Thread: Hard one again :rolleyes:

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Red face

    I have a group of command buttons (lets say cmd(1 to 5))
    My question - I want the backcolor to change when the mouse goes over it - no problem, I use the mousemove / mouseover event whatever it is.
    BUT - I need the backcolor to reset after the mouse has finished passing over it, a sort of mouseover_finish event.

    I could write 10,000 lines to check the axis / co-ordinataes of the mouse, but do I have any easier options please?

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    Lively Member
    Join Date
    Feb 2001
    Location
    Qc, Canada
    Posts
    70
    Hi,

    On the mouse_move of the container of your cmdBouttons, reset the color back to its original. I don't know the layout of your program though...

    Steph
    Virtually Impossible !

    VB5 Entreprise (SP3) - VB6 Entreprise (SP4), MSSQL7, MSAccess, VBA, VBScript, ASP

  3. #3
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575
    Try setting the color back on other mouse over events:

    so:
    Code:
    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    recolorall
    Command1.BackColor = vbRed
    End Sub
    
    sub recolorall()
    Command1.BackColor = &H8000000F
    etc
    end sub
    note: you will have to change the graphical property to true

    place recolorall command in all of the controls and the forms mousemove event.

    Rob

  4. #4
    Guest

    Talking

    Its a shame that MS didn't invent a Mouse_Out event for all of the common controls, its quite a glaring omission in my opinion!

    Anyway, you could set up a timer to call...
    Code:
    Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
    ...every 10th of a second or so, and if the coords are outside any of the buttons then you can change the colours accordingly. API functions such as the one above execute very quickly and should not make a dent on the performance of your application.

    Furthermore, it should take considerably less than 10,000 lines of code!

  5. #5
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    I agree with Steph, just put code in the mouseover event of the container i.e. the form that the controls have been placed on. Easy. So when the mouse moves over a control, it changes colour or whatever, then when it moves over the form (but not over a control) it does whatever you have coded in the form's mousemove event.

  6. #6
    Addicted Member Stephenb's Avatar
    Join Date
    Nov 2000
    Location
    Phoenix, Arizona.
    Posts
    172
    I agree with JamesM and Steph, that appears to be the simplest solution.
    Stephen Boston
    Onward!
    VB6 Pro SP4, VBScript
    A+ Certified Techncian.
    No matter where you go, there you are.

  7. #7
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Of course if your buttons are touching in a line then the container idea won't work under all circumstances so you would want your opposite in the container or any other control you might move over to get to the container.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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