Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Mouse Events Don't Fire if Enable is False

MouseMove events don't occur when the control's Enabled property is set to False. My method tackles this problem and is useful when you want to display the Tooltips or Notes on the status bar, whether the control is enabled or disabled. If the Enabled property is set to False, the control placed behind the control's MouseMove event will be fired when you move the cursor on the control. Duplicate code you write in the Command1_MoseMove in the Label1_MouseMove. Now it works even though your Command1 button disabled. Place these controls on Form1:

  • Command1(0), Command1(1)-Command1 is the control array.
  • Label1(0), Label1(1)-Labels set behind the command1.
  • SSPanel1-Acts as status bar.
     Private Sub Form_Load()
    Dim i As Integer
    For i = 0 To 1
    	Label1(i).Left = Command1(i).Left
    	Label1(i).Top = Command1(i).Top
    	Label1(i).Width = Command1(i).Width
    	Label1(i).Height = _
    Next i
    Command1(0).enabled = false
    Command1(0).Tag = "Button to Add"
    Command1(1).Tag = "Button to Modify"
    Command1(0).Caption = "&Add"
    Command1(1).Caption = "&Modify"
    End Sub
    Private Sub Label1_MouseMove(Index As _
    	Integer, Button As Integer, Shift _
    	As Integer, X As Single, Y As _
    	SSPanel1.Caption = _
    End Sub
    Private Sub Command1_MouseMove(Index _
    	As Integer, Button As Integer, _
    	Shift As Integer, X As Single, Y _
    	As Single)
    	SSPanel1.Caption = _
    End Sub
  • S. Edwin
    Comment and Contribute






    (Maximum characters: 1200). You have 1200 characters left.



    Thanks for your registration, follow us on our social networks to keep up-to-date