Thomas Risi Softwareentwicklung

UserForm ohne Titelleiste

Eine UserForm ohne Titelleiste anzeigen kein Problem ...

Quellcode für die UserForm (mit einem CommandButton) ...

Option Explicit Private Declare Function DrawMenuBar Lib "User32" ( _ ByVal hwnd As Long) As Long Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" ( _ ByVal hwnd As Long, _ ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" ( _ ByVal hwnd As Long, _ ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Const WS_BORDER As Long = &H800000 Const WS_CAPTION As Long = &HC00000 Const WS_EX_WINDOWEDGE As Long = &H100 Const GWL_STYLE As Long = (-16) Const GWL_EXSTYLE As Long = (-20) Dim hwnd& Private Function GetHandleUF(uf As MSForms.UserForm) As Long GetHandleUF = IIf(Int(Val(Application.Version)) < 9, _ FindWindow("ThunderXFrame", uf.Caption), FindWindow("ThunderDFrame", uf.Caption)) End Function Private Sub CommandButton1_Click() Unload Me End Sub Private Sub UserForm_Initialize() hwnd = GetHandleUF(Me) ' Der UF eine hübsche Farbe verpassen (bei Bedarf) Me.BackColor = &H80FFFF ' Die Titelleiste entfernen Call SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) And Not WS_CAPTION) ' Den Rahmen entfernen Call SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_STYLE) And WS_EX_WINDOWEDGE) Call DrawMenuBar(hwnd) End Sub

Bewerten Sie bitte dieses Programm.
1 2 3 4 5
Weniger nützlich Sehr nützlich
Bitte teilen Sie uns mit, warum Sie das Programm so bewertet haben. (optional)