jetzt wende ich mal mal das erste mal an dieses Forum. Vielen Dank erstmal an alle vorherigen Schreiberlinge. Dank euch konnte ich in unserer Firma schon vielen das Staunen ins Gesicht zaubern. Nun zu meinem Thema:
Ich habe folgenden Wunsch... In meiner Userform soll das Kreuz in der Ecke deaktiviert und ausgeblendet werden sowie in der Taskleiste als Fenster (Task) angezeigt werden. Nun folgende Problematik:
Ändere ich folgendes, zeigt er zwar das Kreuz nicht mehr an, dafür aber auch nicht mehr in der Taskleiste:
Private Const GWL_EXSTYLE As Long = -16
Private Const WS_EX_APPWINDOW As LongPtr = &H80000
hMenu = hMenu And Not WS_EX_APPWINDOW
So wie u.a. ist die Userform in der Taskleiste zwar ersichtlich, das Kreuz ist aber sichtbar (aber deaktiviert).
Kann mir jemand helfen?
Der Code ist eingefügt im Formular.
Beste Grüße
Manuel
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 Declare PtrSafe Function DrawMenuBar Lib "user32.dll" ( _
ByVal hWnd As LongPtr) As Long
Private Declare PtrSafe Function GetSystemMenu Lib "user32.dll" ( _
ByVal hWnd As LongPtr, _
ByVal bRevert As LongPtr) As Long
Private Declare PtrSafe Function RemoveMenu Lib "user32.dll" ( _
ByVal hMenu As LongPtr, _
ByVal nPosition As LongPtr, _
ByVal wFlags As LongPtr) As Long
Private Declare PtrSafe Function GetMenuItemCount Lib "user32.dll" ( _
ByVal hMenu As LongPtr) As Long
Private hWnd 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 WS_SYSTEMMENU As LongPtr = &H80000
Private Const SW_HIDE As Long = 0
Private Const SW_SHOW As Long = 5
Private Const MF_BYPOSITION As Long = &H400
Private Const MF_REMOVE As Long = &H1000
Private Sub Userform_Activate()
Dim hWnd As LongPtr
Dim hMenu As LongPtr
Dim menuItemCount As LongPtr
hWnd = FindWindowA(GC_CLASSNAMEUSERFORM, Caption)
hMenu = GetSystemMenu(hWnd, 0)
If CBool(hMenu 0) Then
menuItemCount = GetMenuItemCount(hMenu)
RemoveMenu hMenu, menuItemCount - 1, MF_REMOVE Or MF_BYPOSITION
RemoveMenu hMenu, menuItemCount - 2, MF_REMOVE Or MF_BYPOSITION
DrawMenuBar hWnd
Call ShowWindow(hWnd, SW_HIDE)
hMenu = GetWindowLongA(hWnd, GWL_EXSTYLE)
hMenu = hMenu Or WS_EX_APPWINDOW
Call SetWindowLongA(hWnd, GWL_EXSTYLE, hMenu)
Call ShowWindow(hWnd, SW_SHOW)