Beispiel
Erweiterten Stil des Fensters ändern
(Kleines x/ToolWindow)


Option Explicit

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

'Get/SetWindowLong flags
Const GWL_EXSTYLE As Long = (-20)
Const GWL_STYLE As Long = (-16)

'Extended Window Styles
Const WS_EX_ACCEPTFILES As Long = &H10&
Const WS_EX_APPWINDOW As Long = &H40000
Const WS_EX_CLIENTEDGE As Long = &H200&
Const WS_EX_CONTEXTHELP As Long = &H400&
Const WS_EX_CONTROLPARENT As Long = &H10000
Const WS_EX_DLGMODALFRAME As Long = &H1&
Const WS_EX_LEFT As Long = &H0&
Const WS_EX_LEFTSCROLLBAR As Long = &H4000&
Const WS_EX_LTRREADING As Long = &H0&
Const WS_EX_MDICHILD As Long = &H40&
Const WS_EX_NOPARENTNOTIFY As Long = &H4&
Const WS_EX_RIGHT As Long = &H1000&
Const WS_EX_RIGHTSCROLLBAR As Long = &H0&
Const WS_EX_RTLREADING As Long = &H2000&
Const WS_EX_STATICEDGE As Long = &H20000
Const WS_EX_TOOLWINDOW As Long = &H80&
Const WS_EX_TOPMOST As Long = &H8&
Const WS_EX_TRANSPARENT As Long = &H20&
Const WS_EX_WINDOWEDGE As Long = &H100&
Const WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE Or WS_EX_CLIENTEDGE
Const WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE Or WS_EX_TOOLWINDOW Or WS_EX_TOPMOST

'#if(_WIN32_WINNT >= =&H0500)
Const WS_EX_LAYERED = &H80000
Const WS_EX_NOINHERITLAYOUT = &H100000      'Disable inheritence of mirroring by children
Const WS_EX_LAYOUTRTL = &H400000            'Right to left mirroring
Const WS_EX_COMPOSITED = &H2000000
Const WS_EX_NOACTIVATE = &H8000000

 

Private Sub UserForm_Initialize()

   
   ChangeWindowExStyle
  
End Sub

 

Sub ChangeWindowExStyle()
   Dim lRet As Long
   
   Dim hWnd As Long
   
   hWnd = GetUserFormHandle(Me)
   If hWnd = 0 Then
      MsgBox "Could not get handle to Userform!" & vbCrLf _
         & "Quitting ...", vbOKOnly Or vbCritical, "DisableExit"
      Exit Sub
   End If

   lRet = GetWindowLong(hWnd, GWL_EXSTYLE)
   If lRet <> 0 Then
      SetWindowLong hWnd, GWL_EXSTYLE, lRet Or WS_EX_TOOLWINDOW
   End If
End Sub

 

Function GetUserFormHandle(UF As UserForm) As Long
   Dim hWnd_UF As Long
   
   hWnd_UF = FindWindow("ThunderDFrame", UF.Caption)
   GetUserFormHandle = hWnd_UF
End Function


 Auch hier gilt: Nicht alle Stile sind sinnvoll miteinander kombinierbar.

Auch sind nicht alle Fenster-Stile mit den erweiterten Fensterstilen kombinierbar.

Zum Seitenanfang