AW: Beim Minimieren der Userform Code ausführen
08.12.2015 14:25:58
muehli
Also,
habe versucht mich in das Ganze einzulesen.
Leider muss ich feststellen, dass ich doch nicht so viel verstehe.
Hier mal mein Code:
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 ShowWindow _
Lib "user32" _
(ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long
Private Declare Function DrawMenuBar _
Lib "user32" _
(ByVal nWnd As Long) As Long
Private Declare Function SetFocus _
Lib "user32" _
(ByVal hWnd As Long) As Long
Private Const GWL_STYLE As Long = (-16)
Private Const GWL_EXSTYLE As Long = (-20)
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const WS_EX_APPWINDOW As Long = &H40000
Private Const SW_HIDE As Long = 0
Private Const SW_SHOW As Long = 5
Dim objMinMaxUF As Object
Public Property Set formular(objUF As Object)
Dim lngUFHandle As Long
Dim lngFensterStil As Long
Set objMinMaxUF = objUF
lngUFHandle = FindWindow(vbNullString, objMinMaxUF.Caption)
lngFensterStil = GetWindowLong(lngUFHandle, GWL_STYLE)
lngFensterStil = lngFensterStil Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
SetWindowLong lngUFHandle, GWL_STYLE, lngFensterStil
lngFensterStil = GetWindowLong(lngUFHandle, GWL_EXSTYLE)
lngFensterStil = lngFensterStil Or WS_EX_APPWINDOW
SetWindowLong lngUFHandle, GWL_EXSTYLE, lngFensterStil
ShowWindow lngUFHandle, SW_HIDE
DrawMenuBar lngUFHandle
ShowWindow lngUFHandle, SW_SHOW
SetFocus lngUFHandle
End Property
Ich hätte gerne, dass
Application.visible = true
ausgeführt wird wenn ich die Userform minimiere.
Kann man das realisieren?
Gruß und danke
Muehli