Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form closable
Message
 
To
09/01/2001 17:20:06
Christian Cote
Les Logiciels Onoma Inc.
Longueuil, Quebec, Canada
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00461439
Message ID:
00461581
Views:
14
Christian,

Of course you can take the entire control box off, but if you want to leave
it on for min & max and disable close, you can use the following sub passing the Me.hWnd handle for the form (Calvin and gang have spoiled us VFP'ers by putting all this code under the hood in VFP)...

' API calls to disable form close item
Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public Const MF_BYPOSITION = &H400&

Sub RemoveCloseItem(hWnd as long)
Dim hSysMenu as Long
' Get the system menu for the form
hSysMenu = GetSystemMenu(hWnd, 0)
' Remove the close item
Call RemoveMenu(hSysMenu, 6, MF_BYPOSITION)
' and the seperator
Call RemoveMenu(hSysMenu, 5, MF_BYPOSITION)
End Sub

>HI,
>I need a way to programmatically make a form unclosable (disabling the small x in the upper right corner). In VFP, I simply issue ThisForm.Closable = .F.. How can I do the trick in VB ?
>
>Thank you for your help,
>Christian Cote
Previous
Reply
Map
View

Click here to load this message in the networking platform