Thomas Risi Softwareentwicklung
Addins - Datenbanklösungen - Komponenten - RTDServer - WebServices
UserForm ohne Titelleiste verschieben
Eine UserForm ohne Titelleiste anzeigen kein Problem. Aber mit dem Verschieben der UF ist dann auch vorbei. Aber mit etwas API geht auch das ...
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
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function ReleaseCapture Lib "user32" () 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)
Const HTCAPTION = 2
Const WM_NCLBUTTONDOWN = &HA1
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)
Me.BackColor = &H80FFFF
Call SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) And Not WS_CAPTION)
Call SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_STYLE) And WS_EX_WINDOWEDGE)
Call DrawMenuBar(hwnd)
End Sub
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
End Sub
© 2001 -
by Thomas Risi