Page 2 of 2 FirstFirst 12
Results 41 to 45 of 45

Thread: Detect Lost Focus

  1. #41

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Detect Lost Focus

    yes bushmobile, i set all my label array so it only have one click code.

    rack:
    perhaps there is, we just don't know yet.

  2. #42
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Detect Lost Focus

    Check out this from vbAccelerator. It should allow you to do what you want.

  3. #43

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Detect Lost Focus

    bush, vbaccelerator method is using FORM.
    While i'm trying to avoid using FORM

    In your opinion, what is best method to popup window?
    using FORM with show as modal or using object on the same FORM with combobox behaviour?
    If your preferred method is using FORM how to avoid created so many FORM for each popup windows?

  4. #44
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Detect Lost Focus

    Add the attached module to your project. Now all you have todo is to add the following code to the click event of your button (when you want to show the Frame).
    VB Code:
    1. Private Sub Command1_Click()
    2.     Call HookMouse(Me.hWnd, Frame1.hWnd)
    3. End Sub
    You don't even have to set the Visible property of the Frame to True, everything is handled by the attached code which uses a hook to detect mouse operations within your application and it also subclasses your app to detect if another application gains focus. If the mouse is pressed anywhere inside your application the frame will be hidden, the same happens if your application loses focus.

    To handle the Esc key set the KeyPreview property of the Form to True and add this code:
    VB Code:
    1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If KeyCode = vbKeyEscape Then
    3.         UnhookMouse
    4.     End If
    5. End Sub
    Attached Files Attached Files

  5. #45

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    Re: Detect Lost Focus

    it work like magic joacim
    Thanks.

Page 2 of 2 FirstFirst 12

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