Results 1 to 7 of 7

Thread: vb.net 2003 win form minimize & maximize enabled close disabled

  1. #1
    Join Date
    Mar 2006
    Posts
    35
    Rep Power
    0

    Exclamation vb.net 2003 win form minimize & maximize enabled close disabled

    Hello all,

    I would like to disable use of the windows form ControlBox "X" or close button with out losing the minimize or maximize buttons. Setting the ControlBox = false removes all three options.

    I've tried trapping in the Form.Closing event and it ignores all attempts to abort the cancel and closes the form anyway.

    If anyone has any suggestions on how I can either disable the "X" or close button of the form ControlBox or prevent the form from closing in the Form.Closing event I would greatly appreciate it.


  2. #2
    Join Date
    Mar 2006
    Posts
    35
    Rep Power
    0

    Default

    This site explains how to do something close enough to what I wanted

    http://www.addressof.com/blog/articles/232.aspx
    Unfortunately when you maximize the form the "X" becomes enabled again, to fix this you have to set the MaximizeBox property for the form to false.

    If anyone finds anything better, please let me know. Thank you.

  3. #3
    Join Date
    Sep 2003
    Posts
    603
    Rep Power
    0

    Default

    Quote Originally Posted by woodsprite
    Hello all,

    I would like to disable use of the windows form ControlBox "X" or close button with out losing the minimize or maximize buttons. Setting the ControlBox = false removes all three options.

    I've tried trapping in the Form.Closing event and it ignores all attempts to abort the cancel and closes the form anyway.

    If anyone has any suggestions on how I can either disable the "X" or close button of the form ControlBox or prevent the form from closing in the Form.Closing event I would greatly appreciate it.

    overide the Read Only Property CreateParams

    in VB
    Code:
        Protected Overrides ReadOnly Property CreateParams() As CreateParams
            Get
                Dim CS_NOCLOSE As Integer = Int32.Parse("200", Globalization.NumberStyles.HexNumber)
                Dim cp As CreateParams = MyBase.CreateParams
                cp.ClassStyle = CS_NOCLOSE
                Return cp
            End Get
        End Property
    in C#
    Code:
            protected override CreateParams CreateParams
            {
                get
                {
                    const int CS_NOCLOSE = 0x200;
                    CreateParams cp = base.CreateParams;
                    cp.ClassStyle |= CS_NOCLOSE;
                    return cp;
                }
            }
    easiparcel.com Shop online and ship to Jamaica

  4. #4
    Join Date
    Sep 2003
    Posts
    603
    Rep Power
    0

    Default

    not even a thank you.... geez....
    easiparcel.com Shop online and ship to Jamaica

  5. #5
    Join Date
    Mar 2006
    Posts
    35
    Rep Power
    0

    Default

    cgpGroup,

    I dpn't have regular access to the internet so my responses may be slow. However, I thank you very much. that was exactly what i was looking for and works like a dream! I appreciate the time you spent on this.

  6. #6
    Join Date
    Sep 2004
    Posts
    1,905
    Rep Power
    21

    Default

    Thanks cgp. Both C# and VB.Net codes are helpful and I learn something again.
    Let's act on what we agree on now, and argue later on what we don't.
    Black men leave Barbeque alone if Barbeque don't trouble you

  7. #7
    Join Date
    Dec 2002
    Posts
    500
    Rep Power
    0

    Default dats skillz

    props 4 ma dupes, y' sound like a veteran WIN32 programmer with .NET skills.
    Cultured in Aggression and Koding like a Warrior!!
    “Common sense is instinct. Enough of it is genius.” - George Bernard Shaw.
    "The significant problems we face cannot be solved by the same level of thinking that created them." - Albert Einstein

Posting Permissions

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