Discussion Locked

Forms problem in VB6

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How can I create a ?FORM? that always stay on top of desktop?
i.e. when I open a new program that ?FORM? hide behind the program, what I want is that ?FORM? always remain on top of any program which I open.

7 replies

by mohammad_m_saggaf

You can use SetWindowsPos to do many things. One of them is to adjust its z-order prority as in the following example:

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal yAs Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const HWND_TOPMOST = -1
Private Const SWP_SHOWWINDOW = &H40

Private Sub Form_Load()
Dim Result As Long
Result = SetWindowPos(Me.hwnd, HWND_TOPMOST, Me.Left, Me.Top, Me.Width, Me.Height, SWP_SHOWWINDOW)
End Sub

I hope I helped.

by mohammad_m_saggaf

You can use SetWindowsPos to do many things. One of them is to adjust its z-order priority as in the following example:

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 HWND_TOPMOST = -1
Private Const SWP_SHOWWINDOW = &H40

Private Sub Form_Load()
Dim Result As Long
Result = SetWindowPos(Me.hwnd, HWND_TOPMOST, Me.Left, Me.Top, Me.Width, Me.Height, SWP_SHOWWINDOW)
End Sub

I hope I helped.

This discussion is closed to new replies.