Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Disable form Close button


'declarations
Public Declare Function RemoveMenu Lib "user32" ( ByVal hMenu As Long , _
     ByVal nPosition As Long , ByVal wFlags As Long ) As Long

Public Declare Function GetSystemMenu Lib "user32" ( ByVal hWND As Long , _
     ByVal bRevert As Long ) As Long



'use this code to disable the close button
DisableCloseButton Me .hWND

Public Sub DisableCloseButton(hWND As Long )
    Dim hSysMenu As Long
   hSysMenu = GetSystemMenu(hWND, 0)
   RemoveMenu hSysMenu, 6, &H400&
   RemoveMenu hSysMenu, 5, &H400&
End Sub