|
-
Apr 23rd, 2001, 01:56 AM
#1
Thread Starter
Lively Member
I got this code from a reply. I couldn't find my thread so I couldn't follow it up there. It's suppose to disable the X at the upper right corner of the Window which exits the form.
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Const MF_BYPOSITION = &H400&
Private Sub Form_Load()
RemoveMenu GetSystemMenu(Me.hWnd, 0), 6, MF_BYPOSITION 'removes the "X" box and the System Menu
End Sub
Well, if you'll try this code, it would look as if it would work the way it does. The X would become gray in color, but when I accidentally clicked the button, my form still exits!!!
Please help!!!
-
Apr 23rd, 2001, 06:08 AM
#2
It's disabled for me.
But to keep your form from closing when the X button is clicked, add this to the Form_Unload() or Form_QueryUnload() event(s).
-
Apr 23rd, 2001, 03:36 PM
#3
-
Apr 23rd, 2001, 03:46 PM
#4
Matthew Gates: That code will prevent the Form from closing, but it will prevent it in all cases. What you need to do in this case is to make use of the UnloadMode argument of the QueryUnload() event.
Code:
If UnloadMode = 0 Then Cancel = True
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
|