An Josef & Rainhard
16.09.2006 11:04:40
Heinz
Hallo Josef & Rainhard
Dieser Code ist in der Mappe schon eingefügt.
Hoffe das dies der richtige Code ist.
Könntet Ihr mir Bitte den Code abändern ?
Muss nun auf eine Hochzeit gehen.
Kann erst morgen nachsehen.
Danke an Euch beiden & schönes WE.
Gruss,Heinz
Option Explicit
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
Const WS_BORDER = &H800000
Const WS_CAPTION = &HC00000
Const WS_CHILD = &H40000000
Const WS_HSCROLL = &H100000
Const WS_MAXIMIZE = &H10000000
Const WS_MAXIMIZEBOX = &H10000
Const WS_MINIMIZEBOX = &H20000
Const WS_THICKFRAME = &H40000
Const WS_SIZEBOX = WS_THICKFRAME
Const WS_SYSMENU = &H80000
Const WS_EX_ACCEPTFILES = &H10
Const WS_EX_STATICEDGE = &H20000
Const WS_EX_TOOLWINDOW = &H80
Const WS_EX_TRANSPARENT = &H20
Const WS_EX_WINDOWEDGE = &H100
Const GWL_STYLE = (-16)
Const GWL_EXSTYLE = (-20)
Dim WithEvents myUserForm As MSForms.UserForm
Dim myHandle&, lStyle&, Border&
Dim MaxBox As Boolean, MinBox As Boolean
Public Enum BorderStyles
xlFest = 0
xlÄnderbar = 1
End Enum
Public Sub Create(UF As MSForms.UserForm)
Dim ret&
Set myUserForm = UF
myHandle = GetHandle
SetWindowLong myHandle, GWL_STYLE, GetStyle Or WS_CAPTION Or Border
If MaxBox Then SetWindowLong myHandle, GWL_STYLE, GetStyle Or WS_MAXIMIZEBOX
If MinBox Then SetWindowLong myHandle, GWL_STYLE, GetStyle Or WS_MINIMIZEBOX
SetWindowLong myHandle, GWL_EXSTYLE, GetStyle And WS_EX_STATICEDGE And WS_EX_WINDOWEDGE
End Sub
Private Function GetHandle() As Long
Select Case Int(Val(Application.Version))
Case 8 'Excel 97
GetHandle = FindWindow("ThunderXFrame", vbNullString)
Case 9 'Excel 2000
GetHandle = FindWindow("ThunderDFrame", vbNullString)
Case 10 'Excel XP
GetHandle = FindWindow("ThunderDFrame", vbNullString)
Case 11 'Excel 2003
GetHandle = FindWindow("ThunderDFrame", vbNullString)
End Select
End Function
Public Property Get hwnd() As Boolean
hwnd = myHandle
End Property
Public Property Get MaxButton() As Boolean
MaxButton = MaxBox
End Property
Public Property Let MaxButton(Status As Boolean)
MaxBox = Status
End Property
Public Property Get MinButton() As Boolean
MinButton = MinBox
End Property
Public Property Let MinButton(Status As Boolean)
MinBox = Status
End Property
Public Property Let BorderStyle(Style As BorderStyles)
Select Case Style
Case 0: Border = 0
Case 1: Border = WS_SIZEBOX
End Select
End Property
Private Function GetStyle() As Long
GetStyle = GetWindowLong(myHandle, GWL_STYLE)
End Function
Private Sub Class_Initialize()
MaxBox = False
MinBox = False
End Sub