|
-
Mar 13th, 2002, 09:20 AM
#1
Thread Starter
Lively Member
disabling close button
Hi everyone,
do you know how to disable the close button on a window?
(think this one is really a FAQ).
-
Mar 13th, 2002, 09:35 AM
#2
Frenzied Member
Don't remember where I found this so I can't give anyone the credit. Don't think I have ever even used it. I hope it works for you.
VB Code:
Option Explicit
Private Declare Function GetSystemMenu Lib "user32" _
(ByVal hwnd As Long, _
ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" _
(ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Private Const MF_BYPOSITION = &H400&
Public Function DisableCloseButton(frm As Form) As Boolean
'PURPOSE: Removes X button from a form
'EXAMPLE: DisableCloseButton Me
'RETURNS: True if successful, false otherwise
'NOTES: Also removes Exit Item from
' Control Box Menu
Dim lHndSysMenu As Long
Dim lAns1 As Long, lAns2 As Long
lHndSysMenu = GetSystemMenu(frm.hwnd, 0)
'remove close button
lAns1 = RemoveMenu(lHndSysMenu, 6, MF_BYPOSITION)
'Remove seperator bar
lAns2 = RemoveMenu(lHndSysMenu, 5, MF_BYPOSITION)
'Return True if both calls were successful
DisableCloseButton = (lAns1 <> 0 And lAns2 <> 0)
End Function
-
Mar 13th, 2002, 09:43 AM
#3
Thread Starter
Lively Member
but AL+F4?
It works, but ALT+F4 still works... Any Idea on how to disable this?
-
Mar 13th, 2002, 09:46 AM
#4
Thread Starter
Lively Member
found...
It is just enought to set
Cancel = True
in the Form Query_unload function.
Thanks.
-
Mar 13th, 2002, 10:46 AM
#5
Frenzied Member
I thought about that, but you specifically asked about the Close button.
What exactly do you want to do? Will you be testing for specific values in UnloadMode?
-
Mar 13th, 2002, 11:42 AM
#6
Member
Last edited by phool312; Jan 29th, 2013 at 08:13 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|