AW: Userform in Taskleiste
23.10.2019 15:07:51
Nepumuk
Hallo Sven,
in das Modul des UserForms:
Option Explicit
Private Declare PtrSafe Function FindWindowA Lib "user32.dll" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function GetWindowLongA Lib "user32.dll" ( _
ByVal hwnd As LongPtr, _
ByVal nIndex As Long) As LongPtr
Private Declare PtrSafe Function SetWindowLongA Lib "user32.dll" ( _
ByVal hwnd As LongPtr, _
ByVal nIndex As Long, _
ByVal dwNewLong As LongPtr) As LongPtr
Private Declare PtrSafe Function ShowWindow Lib "user32.dll" ( _
ByVal hwnd As LongPtr, _
ByVal nCmdShow As Long) As Long
Private Const GC_CLASSNAMEUSERFORM As String = "ThunderDFrame"
Private Const GWL_EXSTYLE As Long = -20
Private Const WS_EX_APPWINDOW As LongPtr = &H40000
Private Const SW_HIDE As Long = 0
Private Const SW_SHOW As Long = 5
Private Sub CommandButton1_Click()
Call Unload(Object:=Me)
End Sub
Private Sub UserForm_Activate()
Dim lngptrHwnd As LongPtr, lngptrStyle As LongPtr
lngptrHwnd = FindWindowA(GC_CLASSNAMEUSERFORM, Caption)
Call ShowWindow(lngptrHwnd, SW_HIDE)
lngptrStyle = GetWindowLongA(lngptrHwnd, GWL_EXSTYLE)
lngptrStyle = lngptrStyle Or WS_EX_APPWINDOW
Call SetWindowLongA(lngptrHwnd, GWL_EXSTYLE, lngptrStyle)
Call ShowWindow(lngptrHwnd, SW_SHOW)
End Sub
Gruß
Nepumuk