question 1: how can i make command1 to have a doubleclick event?
question 2: is there a way to highlight command1 like what windows does when you click on an icon?
Printable View
question 1: how can i make command1 to have a doubleclick event?
question 2: is there a way to highlight command1 like what windows does when you click on an icon?
Highlight? You mean like when the command button has tab focus?
Save the Timer variable, and if it is less than 5ms away, then count a second cick.Quote:
Originally Posted by vbcooler
You can change the color of the command button.
can you please give me an exmaple in code or as an attachment?
Do you need to use a command button?
If you use somthing like a label it has a DblClick function built in.
Hojo
THx Hojo, you solved my first question
but i stil want to know if there is a way to make label1 highlight if like if you go to your windows desktop and click only once on any icon it will amke is highlighted in blue
Exactly HOJO! - use Label control or Image control or ... but why going through so much troubles - I don't get it. :rolleyes:
Suggestion: Use a PictureBox; that has a DblClick Event. You could change the text/picture it displays when the mouse moves over it.
Bruce.
Alternatly, have a look at post #6 from this (old) thread: http://www.vbforums.com/showthread.p...ighlight=lable
And,
a simple way (with a Label for example) change the text/background colour etc in the Lables Mouse_Move Event, then reset it when the Mouse moves on the Form.
To do that use the Form's MouseMove_Event; but use a Boolean (Flag) Variable so your not
always cycling the Lable as the Mouse moves over the Form. Yes, the evaluation of the Flag is taking place but thats it. Sooo the method above may be better :)
Bruce.
How Do I Do Muse Over Event?
Here is a sample that changes the color of a button. You can use the same for almost any control.
http://vbforums.com/attachment.php?attachmentid=37991
Place a Lable on a Form and paste the code for a demo:
VB Code:
Option Explicit Dim blnToggleColour As Boolean Private Sub Label1_DblClick() 'Whatever End Sub Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If blnToggleColour = False Then Me.Label1.BackColor = vbRed 'Set the Flag blnToggleColour = True End If End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If blnToggleColour = True Then Label1.BackColor = &H8000000F 'Default colour 'Reset the Flag blnToggleColour = False End If End Sub
Please note that this method isn't bullet proof...
Bruce.
Here is a way to possible get what you want.
Use a textbox as a control
Set its backcolour to "button face"
Set its border to none
Set its appearence to flat and
set its locked property to true
Now you have created a label but a label with a dblclick function a gotfocus function and a lostfocus function then code like so...
VB Code:
Private Sub Text1_GotFocus() Text1.BackColor = vbBlue ' or what ever colour you want End Sub Private Sub Text1_LostFocus() Text1.BackColor = &H8000000F 'Button face colour End Sub Private sub Text1_dblClick() 'do whatever End sub
Hope this helps
Hojo
Hojo,
The only problem with that example is the Text1.BackColor stays until the user 'clicks' on another control!
(Point: LostFocus isn't fired when the Mouse moves off the TextBox)
Bruce.
Isn't that what vbCooler wants?
Like with the icons in windows? They highlight when single click and stay highlighted until somthing else is clicked.
???
Hojo: You might be right, since I re-read Q2 in post #1 :)
Bruce.