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. ;)
Printable View
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. ;)
Use the ZOrder method,
text1.ZOrder 0
will bring the text1 text box to the front of everything else.
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
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:
and you've written the same thing for disabling it!!Code:SetTopMostWindow Me.hwnd, True
anyway, how do I bring it forward, without it appearing over the taskbar??
Thanks, :)
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
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...
more info??
also, would it be good to use API to make:
1) my app on top
2) taskbar on top
?? :confused:
Thanks, :)
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... ?
I hope it works :p
will my idea work?
Thanks for all of your help,