Disable Alt + Space  
Author Message

PostPosted: Visual C# Language, Disable Alt + Space Top

I want to disable the menu that pop-up's in the header when i use the alt+space bar key in .Net. Basically i dont want the menu to be listed.Is there any property for that or is there any api call to disable that. Please help me out in that. Thanks in advance.


Visual C#12  

PostPosted: Visual C# Language, Disable Alt + Space Top

Set the ControlBox property of the form to False.



PostPosted: Visual C# Language, Disable Alt + Space Top

Another solution is to work with the message queue passing through your program. This allows more diversity in what you can control. However you need to be more careful, as you can easily block vital key strokes to your program and even other programs using the override for key previewing.

The problem with just disabling you ControlBox property is that you lose the buttons in the title bar.

Here is a C# example code snippet:

public override bool PreProcessMessage(ref Message msg)
// Always check for your window as the recipient!
if (msg.HWnd == this.Handle)
// msg.Msg 0x104 is for SysKey
// WParam 0x20 is for space key
// LParam 0x20390001 is for space key modified by alt key
if (msg.Msg == 0x104 && msg.WParam.ToInt32() == 0x20 && msg.LParam.ToInt32() == 0x20390001)
// Prevent the message from being process, thus preventing the pop-up
// Use this time to alert anything that you want to know that alt+space was received
msg = new Message();
return base.PreProcessMessage(ref msg);

Just another reminder be very careful when overriding message processors and blocking messages! Make sure they really are meant for your window and that you don't block more than you need to.