Community discussion forum

newbie mouseover with button on form

Tags: vb6 Italy
  • 2 years ago
    Simple...possible to have a mouseover effect on a button of form?
    Use vb 6.0


  • 2 years ago

    Set first the style property of the command button to graphical so that you can see the effect you want in your command button. then make the code in the event on MouseMove or MouseDown.

    sample:

    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Command1.BackColor = vbGreen
    End Sub]

    Hope it would help:

    jirehWink [;)]

  • 2 years ago

    nice...

    Bu admit have many button in form and i want to use for all this button the same color blue and red for mouseover???

  • 2 years ago
    is this what you mean?


    Option Explicit

    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Command1.BackColor = vbRed
    End Sub

    Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Command2.BackColor = vbRed
    End Sub

    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Command1.BackColor = vbBlue
        Command2.BackColor = vbBlue
    End Sub



















  • 2 years ago

    Fantastic....

    Sorry for my english but you have understand me correctly.!

    Good pizza for you, from Napoli.

    Now i have imported in VB project a vba for Excel userform.

    I want to make in this form the same effect you posted, is poissible?

    Sorry for popup when go in the mytempdir site, i dont know other site offer a free upload;-(

     http://www.mytempdir.com/1367503

  • 2 years ago

    I'm sorry but I hadn't try it before, but maybe keith can help you., why don't you try to post your problem there. http://www.martin2k.co.uk/forums/index.php?showforum=4 or in http://www.a1vbcode.com/vbforums/ c u there friend!

  • 2 years ago
    jireh wrote:
    is this what you mean?


    Option Explicit

    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Command1.BackColor = vbRed
    End Sub

    Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Command2.BackColor = vbRed
    End Sub

    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Command1.BackColor = vbBlue
        Command2.BackColor = vbBlue
    End Sub





















    Assuming you had 10 buttons, you could all give them the same name, so they'd become an array - Command1(0) to Command1(9). Then you could add the following to the mouseover event:

    Private Sub Command1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    Command1(Index).BackColor = vbRed
    End Sub

    This saves code and makes it easier to adjust the colour, for example. The code for the Form would, of course, remain the same.









Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!