Results 1 to 3 of 3

Thread: How to check whether my form is Active or Inactive

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Location
    India, Chennai
    Posts
    121

    Exclamation How to check whether my form is Active or Inactive

    Hi Guys,
    I need to know how to check whether my form is Active or Inactive, I mean whether my form's Window is Currently the Active Window or Inactive Window. Please Help me
    Stop Piracy. Stop Using Microsoft.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Use GetForeGroundWindow API.
    VB Code:
    1. Private Declare Function GetForegroundWindow Lib "user32" () As Long
    2.  
    3. Private Sub Timer1_Timer()
    4.     If GetForegroundWindow = MyForm.hWnd Then
    5.         'your form is active
    6.     Else
    7.         'your form is not active
    8.     End If
    9. End Sub

  3. #3
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352

    If you do not wish to use a timer...

    You can either subclass it or set a local hook to track the activation of your window. If you need an example, I can try to post one for you.

    Joe

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