DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2005
    Posts
    32

    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?

  2. #2
    Join Date
    Jan 2005
    Location
    USA
    Posts
    87
    set Controlbox property of the form to False

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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!

  4. #4
    Join Date
    Mar 2005
    Posts
    110
    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

  5. #5
    Join Date
    Aug 2004
    Posts
    25
    i tried that but i got an error message in GetSystemMenu (Sub function not defined)

  6. #6
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    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

  7. #7
    Join Date
    Apr 2005
    Posts
    32
    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.

  8. #8
    Join Date
    Mar 2005
    Posts
    110
    Quote 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.

  9. #9
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Quote 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

  10. #10
    Join Date
    Apr 2005
    Posts
    32
    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links