"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