|
-
Jan 22nd, 2003, 03:11 PM
#1
Thread Starter
Frenzied Member
OK, set forground window problem?
Hey,
OK, if there is already a copy of my application open, i wanna bring that copy to the front,
and then unload the new copy.
Now, it is making the screen flicker, but nothing other then that happens...
should this work?
My app's form caption is "[" & webbrowser PageTitle & "] - The Walks Chat"
so is there something im doing wrong with this, since it dont work proper?
VB Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Form_Load()
If App.PrevInstance = True Then GoTo PrevInst:
' Some code here
Exit Sub
PrevInst:
' Theres a previous open copy of the application,
' so lets bring that copy to the front, and unload this copy
Dim WinHan As Long
WinHan = FindWindow(vbNullString, " - The Walks Chat")
WinHan = SetForegroundWindow(WinHan)
Unload Me
Exit Sub
' More Sub's ETC
End Sub
-
Jan 22nd, 2003, 04:13 PM
#2
There are a couple of problems:
1. You're checking from within a Form, so it would find the form
you're checking from first. You can use findWindowEx() to
search for the next matching window.
2. FindWindow/Ex do not do partial caption matching.
You will need to implement your own function which scans all form
captions looking for a match. (Look at the EnumWindows callback function API.)
-
Jan 22nd, 2003, 07:40 PM
#3
Thread Starter
Frenzied Member
OK, Tnx for the info.
BTW: if i have a form open VBModal to the owning window .. will it bring it forwards then?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|