![]() |
|
Tipp 0213
|
UserForm Schließen-Schaltfläche deaktivieren
|
 |
|
Autor/Einsender: Datum: |
|
Angie 28.03.2002 |
|
| Entwicklungsumgebung: |
|
Excel 97 |
|
|
|
Dieser Tipp zeigt wie man mit Hilfe von API-Funktionen die Schliessen-Schaltfläche ('X') in der
Titelleiste einer UserForm deaktivieren und natürlich bei Bedarf wieder aktivieren kann.
|
|
| 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 GetSystemMenu Lib "user32" (ByVal _
hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal _
hMenu As Long, ByVal nPosition As Long, ByVal wFlags _
As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal _
hwnd As Long) As Long
Private Const SC_CLOSE As Long = &HF060
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
Dim hSysMenu As Long
If hWndForm = 0 Then Exit Sub
If bCloseBtn Then
hSysMenu = GetSystemMenu(hWndForm, 1)
Else
hSysMenu = GetSystemMenu(hWndForm, 0)
DeleteMenu hSysMenu, SC_CLOSE, 0&
End If
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 (13,7 kB)
|
Downloads bisher: [ 1472 ]
|
|
|