|
-
Oct 7th, 2000, 04:54 PM
#1
Thread Starter
Addicted Member
How can u keep your app Always Selected? Say if another program interferes and switches avtiveness to itself, how do you get your app automatically selected back?
Something like this for example:
Private Sub Timer1_Timer()
If Form1.NotSelected = True Then
Form1.Select
Else
End Sub
(BTW, this code doesn't work)
Can someone please help?
Thanx,
Mikelo
-
Oct 7th, 2000, 05:04 PM
#2
Use the SetForegroundWindow and GetForegroundWindow api functions.
Code:
Declare Function GetForegroundWindow Lib "user32.dll" () As Long
Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As Long) As Long
Private Sub Timer1_Timer()
Dim hforewnd As Long
Dim handl As Long
handl = Me.hWnd
hforewnd = GetForegroundWindow()
If handl <> hforewnd Then
SetForegroundWindow handl
Else
End If
End Sub
-
Oct 7th, 2000, 05:19 PM
#3
Thread Starter
Addicted Member
Thanx so much......
Thank you Sooo much, i have been looking for this code for a while now and no websites had it.
Thanx,
Mikelo
-
Oct 7th, 2000, 05:26 PM
#4
You can use this code as well:
Code:
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos"_
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Global Const SWP_NOMOVE = 2
Global Const SWP_NOSIZE = 1
Global Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2
Private Sub Timer1_Timer()
ontop& = SetWindowPos (Me.hWnd, HWND_TOPMOST, _
0, 0, 0, 0, FLAGS)
End Sub
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
|