Library code snippets

Changing the look of command button

Changing the look of command button

This code will change the font of the command button to bold when the mouse moves over it and it will become default when the mouse moves out. You can change anything for command button or any other GUI control.  
---------------------------------
Put a commandbutton on the center of the form and put this code in:

Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.FontBold = True

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.FontBold = False
End Sub

Comments

  1. 25 Feb 2004 at 03:51

    At the first glance of the title, I thought I found what I looking for. No... VB has such a boring command button. And I was trying to add an image to it and set the left/right alignment. No way I can. It's always up and down. So I searched the internet but couldn't find a cue. Is there a way to do it? Please tell me. Thanks.

  2. 22 Dec 2003 at 04:16

    try this


    create a array of the command button
    Option Explicit


    Private Sub Command1_Click(Index As Integer)
       Select Case Index
           Case 0
               MsgBox "Button1"
           Case 1
               MsgBox "Button2"
           Case 2
               MsgBox "Button3"
       End Select
    End Sub


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


    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
       Dim i As Integer
       With Command1
           For i = 0 To .Count - 1
               .Item(i).FontBold = False
           Next
       End With
    End Sub

  3. 12 Dec 2003 at 15:19

    I am a total noob 2 visual basic......so i was wonderin is there a way 2 get this piece of code 2 affect every single command button in a project???  

  4. 01 Jan 1999 at 00:00

    This thread is for discussions of Changing the look of command button.

Leave a comment

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

 Abdul

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

We'd love to hear what you think! Submit ideas or give us feedback