![]() |
|
Tipp 0214
|
UserForm Schließen-Schaltfläche entfernen
|
 |
|
Autor/Einsender: Datum: |
|
Angie 28.03.2002 |
|
| Entwicklungsumgebung: |
|
Excel 97 |
|
|
|
Im Tipp UserForm Schließen-Schaltfläche deaktivieren wurde gezeigt,
wie man die Schließen-Schaltfläche ('X') einer UserForm deaktivieren und bei Bedarf wieder aktivieren kann.
Hier nun der Code um die Schließen-Schaltfläche gänzlich aus der Titelleiste zu entfernen.
|
|
| Code im Codebereich der UserForm |
|
| |
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
Private Declare Function DrawMenuBar Lib "user32" (ByVal _
hwnd As Long) As Long
Private Const GWL_STYLE As Long = -16
Private Const WS_SYSMENU As Long = &H80000
Private hWndForm As Long
Private bCloseBtn As Boolean
Private Sub UserForm_Initialize()
If Val(Application.Version) >= 9 Then
hWndForm = FindWindow("ThunderDFrame", Me.Caption)
Else
hWndForm = FindWindow("ThunderXFrame", Me.Caption)
End If
bCloseBtn = False
SetUserFormStyle
End Sub
Private Sub SetUserFormStyle()
Dim frmStyle As Long
If hWndForm = 0 Then Exit Sub
frmStyle = GetWindowLong(hWndForm, GWL_STYLE)
If bCloseBtn Then
frmStyle = frmStyle Or WS_SYSMENU
Else
frmStyle = frmStyle And Not WS_SYSMENU
End If
SetWindowLong hWndForm, GWL_STYLE, frmStyle
DrawMenuBar hWndForm
End Sub
Private Sub optCloseOn_Click()
bCloseBtn = True
cmdBeenden.Cancel = True
SetUserFormStyle
End Sub
Private Sub optCloseOff_Click()
bCloseBtn = False
cmdBeenden.Cancel = False
SetUserFormStyle
End Sub
|
|
|
|
|
|
|
|
|
|
Die im Download befindliche *.frm-Datei kann für Word und PowerPoint im
jeweiligen Programm im VB-Editor importiert werden.
|
|
| Windows-Version |
| 95 |
 |
|
| 98/SE |
 |
|
| ME |
 |
|
| NT |
 |
|
| 2000 |
 |
|
| XP |
 |
|
| Vista |
 |
|
| Win
7 |
 |
|
|
| Anwendung/VBA-Version |
| Access 97 |
 |
| Access 2000 |
 |
| Access XP |
 |
| Access 2003 |
 |
| Access 2007 |
 |
| Access 2010 |
 |
|
| Excel 97 |
 |
| Excel 2000 |
 |
| Excel XP |
 |
| Excel 2003 |
 |
| Excel 2007 |
 |
| Excel 2010 |
 |
|
| Word 97 |
 |
| Word 2000 |
 |
| Word XP |
 |
| Word 2003 |
 |
| Word 2007 |
 |
| Word 2010 |
 |
|
| PPT 97 |
 |
| PPT 2000 |
 |
| PPT XP |
 |
| PPT 2003 |
 |
| PPT 2007 |
 |
| PPT 2010 |
 |
|
| Outlook 97 |
 |
| Outlook 2000 |
 |
| Outlook XP |
 |
| Outlook 2003 |
 |
| Outlook 2007 |
 |
| Outlook 2010 |
 |
|
|
|
Download (11,3 kB)
|
Downloads bisher: [ 1392 ]
|
|
|