|
-
Apr 1st, 2002, 08:29 AM
#1
Thread Starter
Fanatic Member
Bring window to front..
How do I bring the window to the front of all others??
I dont want to use always on top api, just bring it forward, and allow it to losefocus again..
know what i mean? 
Thanks.
/: Tim :\____________________
\: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/
-
Apr 1st, 2002, 08:37 AM
#2
Member
ZOrder
Use the ZOrder method,
text1.ZOrder 0
will bring the text1 text box to the front of everything else.
-
Apr 1st, 2002, 08:45 AM
#3
Frenzied Member
Declarations:
VB Code:
Private Declare Function SetWindowPos Lib "user32" (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
Private Const SWP_NOMOVE = 2
Private Const SWP_NOSIZE = 1
Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Function SetTopMostWindow(hwnd As Long, Topmost As Boolean) As Long
On Error Goto ErrRtn
If (Topmost) Then
SetTopMostWindow = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
Else
SetTopMostWindow = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
SetTopMostWindow = False
End If
Exit Function
ErrRtn:
MsgBox "Error in SetTopMostWindow " & Err & " " & Error, vbExclamation + vbOKCancel
End Function
To make it ontop:
VB Code:
Private Sub Form_Load()
SetTopMostWindow Me.hwnd, True
End Sub
To disable, just run:
VB Code:
SetTopMostWindow Me.hwnd, False
Last edited by TomGibbons; Apr 5th, 2002 at 01:50 PM.
-
Apr 1st, 2002, 09:12 AM
#4
Thread Starter
Fanatic Member
yeah, im using that at the moment.. the problem is that I dont want it to be over the windows taskbar...
also, your code says:
Code:
SetTopMostWindow Me.hwnd, True
and you've written the same thing for disabling it!!
anyway, how do I bring it forward, without it appearing over the taskbar??
Thanks,
/: Tim :\____________________
\: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/
-
Apr 1st, 2002, 09:31 AM
#5
Frenzied Member
I am wondering why somebody not use the following code to accomplish what you are saying....
'''''''
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Sub Timer1_Timer()
SetForegroundWindow Me.hwnd
End Sub
-
Apr 1st, 2002, 09:50 AM
#6
Frenzied Member
Don't get confused by Timer control!! I just put it to check the code... just call the setForegroundwindow whenever you want to make the window in Focus...
-
Apr 1st, 2002, 10:03 AM
#7
Thread Starter
Fanatic Member
more info??
also, would it be good to use API to make:
1) my app on top
2) taskbar on top
??
Thanks,
/: Tim :\____________________
\: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/
-
Apr 1st, 2002, 10:17 AM
#8
Frenzied Member
1)
My code will make your application on top
2)
to make task bar on top just get its handler through FindWindow API and then pass it in place of me.hwnd
Any more details... ?
-
Apr 1st, 2002, 10:27 AM
#9
Thread Starter
Fanatic Member
I hope it works
will my idea work?
Thanks for all of your help,
/: Tim :\____________________
\: VB, HTML, ASP, VBScript, QBASIC, JavaScript :/
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
|