Visual Basic - Technik, FAQ, Tricks, Beispiele

Home / Objekte / Form / Position

Ein vordergründiges Formular

Impressum
Kontakt
DSVGO
Mit folgendem Code ist es möglich, ein Formular derart in den Vordergrund zu bringen, dass selbst andere aktive Anwendungen dahinter bleiben:
Private Declare Sub 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)

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

Sub SetFormPos( _
    ByRef frm As Form, _
    Optional ByVal TopMost As Boolean = True)
  
  If TopMost Then
    SetWindowPos frm.hWnd, HWND_TOPMOST, _
        0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
  Else
    SetWindowPos frm.hWnd, HWND_NOTOPMOST, _
        0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
  End If
End Sub

© Jost Schwider, 17.08.2000-17.08.2000 - http://vb-tec.de/sformpos.htm