How do i make my form ONTOP of those free internet ads, and it stay thatway.
Printable View
How do i make my form ONTOP of those free internet ads, and it stay thatway.
Use the SetWindowPos api function.
Code: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
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 Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
ontop& = SetWindowPos (Me.hWnd, HWND_TOPMOST, _
0, 0, 0, 0, FLAGS)
End Sub
i put Declarations in Modules, and put code in form_load and timer1_timer event but when i run the program it tell me that 'SetWindowPos' Sub or Function not defined.
[/code] [/B][/QUOTE]
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
Matthew Gates: You don't need to place your code in a Timer, because you will be repeating the same code over and over for nothing. All you really need is to place it in the Load event.
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 Sub Form_Load()
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, 3
End Sub
Oh yeah, silly mistake. Stays on top all the time :rolleyes:.