• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

form that's always-on-top

This is a pretty simple question:
My main form opens another small form. I want the smaller form to always be on top of the main form until the smaller one is closed out. In VB .NET, I think a form has an "AlwaysOnTop" property, but I'm working in VB6 right now and I can't figure out how to do it.
0
vitanza
Asked:
vitanza
1 Solution
 
SpineyNormanCommented:
If Form1 is the name of the smaller form you are showing, then
you can use

Form1.Show vbModal

0
 
GivenRandyCommented:
If you only want your form to be at the top of other forms within your app, rather than being on top of all windows (including other apps):

frmTop.Show vbModeless, frmParent

This will bring the form above its parent (specified as the second parameter).

If a MessageBox appears below the TopMost window and you want it above it instead, then use the vbSystemModal constant in the MsgBox function's Style attribute (this forces the MessageBox to show on top of the AlwaysOnTop form).
0
 
DocMCommented:

'you need to use API functions:

'Win32API functions
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

'Win32API constants
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2

Private Sub Command1_Click()
    SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub

Private Sub Command2_Click()
    SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now