I need to know whether or not a UserForm of which I know the Handle has been added to the Task Bar.
There is a subject that seems to address the same issue but I don’t understand what is its outcome.
Would this code be fine in 32bits & 64bits ?
#If Win64 Then
Private Declare PtrSafe Function GetWindowLongPtr Lib "user32" Alias "GetWindowLongPtrA" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As LongPtr
#Else
Private Declare PtrSafe Function GetWindowLongPtr Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As LongPtr
#End If
'Window field offsets for GetWindowLong() or SetWindowLong()
Private Const GWL_HWNDPARENT = (-8)
Private Const GWL_STYLE = (-16)
Private Const GWL_EXSTYLE = (-20)
'Extended Window Style
Private Const WS_EX_APPWINDOW = &H40000
Private Const WS_EX_TOOLWINDOW = &H80
Function IsUserFormInTaksBar(UserFormHandle As Variant) As Boolean
Dim iStyle As Variant
iStyle = GetWindowLongPtr(UserFormHandle, GWL_EXSTYLE)
IsUserFormInTaksBar = CBool(iStyle And (WS_EX_APPWINDOW Or WS_EX_TOOLWINDOW))
End Function
1