UserForm_Activate
26.04.2005 07:27:40
Torsten
ich habe eine komplexere UF welche im Vollbildmodus sichtbar ist. Diese hat Min/Max Buttons. Der Code dafüt ist unten beigefügt.
Das Problem: Ich rufe per Button eine 2. UF auf und schliesse diese dann wieder. Wenn ich nun auf die 1. UF klicke, flackert der Bildschirm einmal auf was sehr stört. Es liegt eindeutig am Userform_Activate Ereignis. Dieses Flackern llässt sich auch nicht mit Screenupdating = False unterbinden.
Hat da jemand eine Idee?
Vielen Dank schon mal,
Torsten
Private Sub UserForm_Activate()
On Error Resume Next
Application.ScreenUpdating = False
Set objDieseUF.formular = Me
End Sub
Klassenmodul:
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