CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    318

    Form losing mouse

    How could i detect that a form lost the mouse focus, it means the mouse move on another part but not on the form.

    How could i detect that another form takes the focus.

    Note that the other form could be a form of another application.

    thanks



  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Form losing mouse

    To detect that focus has shifted to/from your application you should get the VBEventCTL.ocx control from http://www.merrioncomputing.com/Download/index.htm

    Drop the VBEventWindow control from that package onto your app's amin form and in the form load put:

    private Sub Form_Load()

    VBEventWindow1.ParentForm = me.hWnd

    End Sub




    Then whatever code you want to execute when your app gains or loses the focus should go in the ActiveApplicationChanged event:

    private Sub VBEventWindow1_ActiveApplicationChanged(byval ActivatingThisApp as Boolean, byval hThread as Long, Cancel as Boolean)

    If ActivatingThisApp then
    'My program is regaining focus
    else
    'My program is losing focus to hThread program
    End If

    End Sub




    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

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

Featured