How can I disable right click on title bar of the form and prevent showing system context menu:
Help me to get out of this issue
thank you
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With