"X"-Schaltfläche deaktivieren
[Windows 95/98/NT/2000]

30.12.1998


Um das Schließen einer Form über die "X"-Schaltfläche zu verhindern,
    können Sie diese deaktivieren.
    Außerdem können Sie das Systemmenü entsprechend manipulieren:

ERFORDERLICHE OBJEKTE
   -- keine -- 

FORM-CODE

   Private Declare Function GetSystemMenu Lib "user32" _
      (ByVal hwnd As Long, ByVal bRevert As Long) As Long
   Private Declare Function GetMenuItemCount Lib "user32" _
      (ByVal hMenu As Long) As Long
   Private Declare Function DrawMenuBar Lib "user32" _
      (ByVal hwnd As Long) As Long
   Private Declare Function RemoveMenu Lib "user32" _
      (ByVal hMenu As Long, ByVal nPosition As Long, _
      ByVal wFlags As Long) As Long
   Const MF_BYPOSITION = &H400&
   Const MF_REMOVE = &H1000&
   Private Sub Form_Load()
      Dim SysMenu As Long
      Dim C As Long
      SysMenu = GetSystemMenu(Me.hwnd, False)
      If SysMenu Then
         C = GetMenuItemCount(SysMenu)
         If C Then
            'Menü disablen
            RemoveMenu SysMenu, C - 1, MF_BYPOSITION Or MF_REMOVE
            '"X" disablen
            RemoveMenu SysMenu, C - 2, MF_BYPOSITION Or MF_REMOVE
            DrawMenuBar Me.hwnd
         End If
      End If
   End Sub

 

Download -  2 KB