Results 1 to 40 of 59

Thread: Disable Close Button and Prevent Form Being Moved

Threaded View

  1. #11

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Disable Close button

    Attached is a helper class that you can use to affect the Move and Close item on a form's system menu. If you remove the Move item the user cannot move the form by dragging it. If you grey-out, disable or remove the Close item the Close button on the title bar will be disabled and so will the Alt+F4 key combination. To use it you need just one line of code. Just create an instance in your form like this:
    VB Code:
    1. Private menuManager As New SystemMenuManager(Me, False, SystemMenuManager.MenuItemState.Greyed)
    and everything else is done for you. Note that if you disable the Close item then you must provide an alternative method of closing the form. Note also that this class addresses the issue that anna7 picked up earlier. It implements the solution that JuggaloBrotha suggested internally.

    Edit:
    Attachment removed. See post #1.
    Last edited by jmcilhinney; Sep 30th, 2005 at 05:38 AM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width