devxlogo

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 IntegerFor 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 = _		Command1(i).Height	Next iCommand1(0).enabled = falseCommand1(0).Tag = "Button to Add"Command1(1).Tag = "Button to Modify"Command1(0).Caption = "&Add"Command1(1).Caption = "&Modify"End SubPrivate Sub Label1_MouseMove(Index As _	Integer, Button As Integer, Shift _	As Integer, X As Single, Y As _	Single)	SSPanel1.Caption = _		Command1(Index).TagEnd SubPrivate Sub Command1_MouseMove(Index _	As Integer, Button As Integer, _	Shift As Integer, X As Single, Y _	As Single)	SSPanel1.Caption = _		Command!(Index).tagEnd Sub

    Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

    See also  Seven Service Boundary Mistakes That Create Technical Debt
  • About Our Editorial Process

    At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

    See our full editorial policy.