how do make my form always on top of other form in my application without using modal
Printable View
how do make my form always on top of other form in my application without using modal
There is a way to do it Here
(I'm not sure if thats the best way)
To keep a program window on top (always visible) in Visual Basic use a WINAPI function. Code in Main Module:
Code in a Submodule:Code:Declare Sub SetWindowPos Lib "User" (Byval hWnd as integer, Byval hWndInsertAfter as Integer, Byval X as Integer, Byval Y as Integer, Byval cx as Integer, Byval cy as Integer, Byval wFlags as Integer)
Code:SetWindowPos form1.hWnd, -1, 0, 0, 0, 0, &H50 'This will make the window always visible!
SetWindowPos form1.hWnd, -2, 0, 0, 0, 0, &H50 'This will put "Always Visible" off!
just give a try...coz I never used this
its not working,
what i actually want is that my form will be placed on top of every form in my application without being on top of ther applications.
Try thisCode:Form2.Show vbModeless, Me
Module:
FormCode:Option Explicit
Public Const HWND_TOPMOST = -1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public 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
Code:Private Sub Command1_Click() ' activate
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE
End Sub
Private Sub Command2_Click() ' deactivate
SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE
End Sub
if GetTopWindow(0) <> form1.hwnd then
'setwindowpos
end if
Rich
thanx for the help guys