Disable form's context menu

usvpn

Freshman
Joined
Apr 19, 2010
Messages
45
Hi,
I need to disable the form's context menu, when you right click on a form's caption bar a context menu appear.
Please see my snapshot.
How to do that in VB.NET?
Thank you.
 

Attachments

You could set the Form's ControlBox property to false. That would completely remove the context menu. Is it important to still display the disabled close button?

To do that you need to add this :

Code:
    Private Const CP_NOCLOSE_BUTTON As Integer = &H200

    Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim myCp As CreateParams = MyBase.CreateParams
            myCp.ClassStyle = myCp.ClassStyle Or CP_NOCLOSE_BUTTON
            Return myCp
        End Get
    End Property
 
Last edited:
Back
Top