-
to disable the close button in top right corner of modalform
If I want to disable the close button in top right corner of modalform how to do it?
-
set Controlbox property of the form to False
-
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
Try this one:
Private Sub Form_Load()
RemoveMenus Me, False, False, _
False, False, False, True, True
End Sub
Private Sub RemoveMenus(ByVal frm As Form, _
ByVal remove_restore As Boolean, _
ByVal remove_move As Boolean, _
ByVal remove_size As Boolean, _
ByVal remove_minimize As Boolean, _
ByVal remove_maximize As Boolean, _
ByVal remove_seperator As Boolean, _
ByVal remove_close As Boolean)
Dim hMenu As Long
'disable system close botton
' Get the form's system menu handle.
hMenu = GetSystemMenu(frm.hwnd, False)
If remove_close Then DeleteMenu hMenu, 6, MF_BYPOSITION
If remove_seperator Then DeleteMenu hMenu, 5, MF_BYPOSITION
If remove_maximize Then DeleteMenu hMenu, 4, MF_BYPOSITION
If remove_minimize Then DeleteMenu hMenu, 3, MF_BYPOSITION
If remove_size Then DeleteMenu hMenu, 2, MF_BYPOSITION
If remove_move Then DeleteMenu hMenu, 1, MF_BYPOSITION
If remove_restore Then DeleteMenu hMenu, 0, MF_BYPOSITION
End Sub
-
i tried that but i got an error message in GetSystemMenu (Sub function not defined)
-
Use the API add-in and add the missing definitions.
To whygh: bad bad boy next time you post some code remember to add also the API declaration... I am smiling because I bet I did that myself in the past!
Marco
"There are two ways to write error-free programs. Only the third one works."
Unknown
-
Thanx guys for your replies.
If I used api, can I revert back by having again, the close button of modal form enabled. I have a need to disable the close button only if a condition is true. once close button is disabled how to revoke it at some other point of code.
-
 Originally Posted by mstraf
Use the API add-in and add the missing definitions.
To whygh: bad bad boy  next time you post some code remember to add also the API declaration... I am smiling because I bet I did that myself in the past!
Marco
Hi ,
Actually yes, I searched some codes about it in the internet. only yours works.
Thanks. I put it in my program.
-
 Originally Posted by maheeru
Thanx guys for your replies.
If I used api, can I revert back by having again, the close button of modal form enabled. I have a need to disable the close button only if a condition is true. once close button is disabled how to revoke it at some other point of code.
yes you can: GetSystemMenu myform.hwnd, 1
Marco
"There are two ways to write error-free programs. Only the third one works."
Unknown
-
1)If I call RemoveMenus function after giving frmModal.show, it takes 3 clicks on x for the close button to be disabled. But If I call frmModal.show after calling Removemenus function it works well. What is the reason behind that?
2) I want to assign a value to a flag while x right corner close button is clicked on a vbmodal form, when it is enabled. I guess the moment one clicks that x button could be trapped using api. Anybody knowing it let me know.
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks