Results 1 to 26 of 26

Thread: Image & Text On A Standard Command Button (Not Graphical Style!)- XP/2K/98

Threaded View

  1. #26
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,728

    Re: Image & Text On A Standard Command Button (Not Graphical Style!)- XP/2K/98

    I would like to share some improvements I have made. (changes in bold)

    Code:
    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If X < 0 Or Y < 0 Or X > EventsCommandButton.Width Or Y > EventsCommandButton.Height Then
        If Button = vbLeftButton Then
            Picture1.Enabled = True  ' if using Picture1 as a dummy control, we'll make sure it is enabled, otherwise the SetFocus method will trigger an error
            Picture1.SetFocus
            Command1.SetFocus
            Picture1.Enabled = False  ' disable the Picture1
            Picture1.Move picleft, pictop
            Picture1.Refresh
        End If
    End If
    End Sub
    Code:
    Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then
            Picture1.Move picleft, pictop
            Picture1.Refresh
        End If
    End Sub
    Code:
    Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbLeftButton Then
            Picture1.Move picleft, pictop
            Picture1.Refresh
        End If
    End Sub
    This I have added to react when hitting the space key on the command button (like mouse clicking):
    Code:
    Private Sub Command1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeySpace Then Picture1.Move picleft + 15, pictop + 15
    End Sub
    
    Private Sub Command1_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeySpace Then Picture1.Refresh
    End Sub
    
    Private Sub Command1_KeyUp(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeySpace Then Picture1.Move picleft, pictop
    End Sub
    Last edited by Krool; Jun 8th, 2012 at 02:01 PM.

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