Results 1 to 16 of 16

Thread: Command1 doubleclick event???

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    35

    Question Command1 doubleclick event???

    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?

  2. #2
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736

    Re: Command1 doubleclick event???

    Highlight? You mean like when the command button has tab focus?

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Command1 doubleclick event???

    Quote Originally Posted by vbcooler
    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?
    Save the Timer variable, and if it is less than 5ms away, then count a second cick.

    You can change the color of the command button.

  4. #4

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    35

    Re: Command1 doubleclick event???

    can you please give me an exmaple in code or as an attachment?

  5. #5
    Lively Member Hojo's Avatar
    Join Date
    Jul 2005
    Location
    Brisbane, Australia
    Posts
    119

    Re: Command1 doubleclick event???

    Do you need to use a command button?

    If you use somthing like a label it has a DblClick function built in.

    Hojo
    Despite body and mind, my youth will never die!

    Everytime I learn something new it pushes some old stuff out of my brain!

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    35

    Re: Command1 doubleclick event???

    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

  7. #7
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Command1 doubleclick event???

    Exactly HOJO! - use Label control or Image control or ... but why going through so much troubles - I don't get it.

  8. #8
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Command1 doubleclick event???

    Suggestion: Use a PictureBox; that has a DblClick Event. You could change the text/picture it displays when the mouse moves over it.




    Bruce.

  9. #9
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Command1 doubleclick event???

    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.

  10. #10

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    35

    Re: Command1 doubleclick event???

    How Do I Do Muse Over Event?

  11. #11
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Command1 doubleclick 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

  12. #12
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Command1 doubleclick event???

    Place a Lable on a Form and paste the code for a demo:
    VB Code:
    1. Option Explicit
    2.  
    3. Dim blnToggleColour As Boolean
    4.  
    5. Private Sub Label1_DblClick()
    6.     'Whatever
    7. End Sub
    8.  
    9. Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    10.  
    11.     If blnToggleColour = False Then
    12.  
    13.         Me.Label1.BackColor = vbRed
    14.         'Set the Flag
    15.         blnToggleColour = True
    16.  
    17.     End If
    18.  
    19. End Sub
    20.  
    21. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    22.  
    23.     If blnToggleColour = True Then
    24.  
    25.         Label1.BackColor = &H8000000F   'Default colour
    26.  
    27.         'Reset the Flag
    28.         blnToggleColour = False
    29.        
    30.     End If
    31.  
    32. End Sub


    Please note that this method isn't bullet proof...



    Bruce.

  13. #13
    Lively Member Hojo's Avatar
    Join Date
    Jul 2005
    Location
    Brisbane, Australia
    Posts
    119

    Re: Command1 doubleclick event???

    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:
    1. Private Sub Text1_GotFocus()
    2.  
    3. Text1.BackColor = vbBlue ' or what ever colour you want
    4.  
    5. End Sub
    6.  
    7. Private Sub Text1_LostFocus()
    8.  
    9. Text1.BackColor = &H8000000F  'Button face colour
    10.  
    11. End Sub
    12.  
    13. Private sub Text1_dblClick()
    14.  
    15. 'do whatever
    16.  
    17. End sub

    Hope this helps

    Hojo
    Despite body and mind, my youth will never die!

    Everytime I learn something new it pushes some old stuff out of my brain!

  14. #14
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Command1 doubleclick event???

    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.

  15. #15
    Lively Member Hojo's Avatar
    Join Date
    Jul 2005
    Location
    Brisbane, Australia
    Posts
    119

    Re: Command1 doubleclick event???

    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.


    ???
    Despite body and mind, my youth will never die!

    Everytime I learn something new it pushes some old stuff out of my brain!

  16. #16
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Command1 doubleclick event???

    Hojo: You might be right, since I re-read Q2 in post #1


    Bruce.

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