PDA

Click to See Complete Forum and Search --> : Always on top window ..


Dasiths
Apr 29th, 2001, 09:39 AM
Hi,
I have this code to put a form always on top but I don't know how to get it to work.

_________________________________________________

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 = &H2
Private Const SWP_NOSIZE = &H1
Private Const HWND_NOTOPMOST = -2
Private Const HWND_TOPMOST = -1

Public Function WinSetFloating(ByVal pHwnd As Long, _
ByVal flOnTop As Boolean) As Boolean

' Sets a window to float or releases it
Dim llngRet As Long
Dim llngMess As Long

If flOnTop = True Then
llngMess = HWND_TOPMOST
Else
llngMess = HWND_NOTOPMOST
End If

llngRet = SetWindowPos(pHwnd, llngMess, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)

If llngRet = 0 Then
Err.Raise APIWinErrors.FLOATING_NOT_SET, "WinSetFloating", _
"Windows has not been set on top."
WinSetFloating = False
Else
WinSetFloating = True
End If

End Function

_______________________________________________


I just copied that code to the code view window.
How can I call that command.

this
________________-

Call WinSetFloating

______________________

won't work.


Please help me..

Megatron
Apr 29th, 2001, 09:48 AM
Private 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

Private Sub Form_Load()
SetWindowPos hwnd, -1, 0,0,0,0,3
End Sub

Olly
Apr 29th, 2001, 09:54 AM
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
Public res As Integer
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

'and

Private Sub Command1_Click()
If res = 0 Then
SetWindowPos Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
res = 1
ElseIf res = 1 Then
SetWindowPos Form1.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
res = 0
End If
End Sub