Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent showing system context menu on right click on Form title bar

How can I disable right click on title bar of the form and prevent showing system context menu:

enter image description here

Help me to get out of this issue

thank you

like image 692
Nishtha Tarini Avatar asked Nov 21 '19 11:11

Nishtha Tarini


1 Answers

If you specifically want to disable showing system context menu on right click on window's title bar, you can handle WM_CONTEXTMENU:

const int WM_CONTEXTMENU = 0x007B;
protected override void WndProc(ref Message m)
{
    if (m.Msg == WM_CONTEXTMENU)
        m.Result = IntPtr.Zero;
    else
        base.WndProc(ref m);
}

If you also want to prevent the possibility of clicking on form's icon to show the context menu, then you can set ShowIcon property of the form to false:

this.ShowIcon = false;
like image 189
Reza Aghaei Avatar answered Oct 19 '22 19:10

Reza Aghaei