Results 1 to 3 of 3

Thread: how to restore backcolor of command button

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    how to restore backcolor of command button

    hi friends
    initially backcolor of command button has one particular color ( say RED), when mouse moves over it the backcolor of command button should be changed to some another color (say GREEN) and original color (i.e RED) should be restore back when mouse moves out of the command button.please help me. thank you.

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: how to restore backcolor of command button

    Here's the simplest way:
    Code:
    Option Explicit
      Private Const ON_MOUSE_IN As Long = vbGreen
      Private Const ON_MOUSE_OUT As Long = vbRed
      
    Private Sub Form_Load()
      Command1.BackColor = ON_MOUSE_OUT
    End Sub
        
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
      If Command1.BackColor <> ON_MOUSE_OUT Then Command1.BackColor = ON_MOUSE_OUT
    End Sub
            
    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
      If Command1.BackColor <> ON_MOUSE_IN Then Command1.BackColor = ON_MOUSE_IN
    End Sub
    Also - don't forget to set your CMD's .Style Property to 1 - Graphical. Since it's a read only Property you can't do it in run-time. So, do it in design time.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2008
    Posts
    27

    Re: how to restore backcolor of command button

    thank you sir.

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