views:

143

answers:

3

Hello, I am creating a Winforms application without any Toolbars. The main window has FormBorderStyle set to Sizable and ControlBox is set to true. Every time I hit Alt and then use up or down arrow (not Alt+Up or Alt+Down) the control box shows up on the top left hand side of my application. This is annoying because there are shortcuts like Alt+R available in my grid, and if the user just presses and releases Alt key and then the Up arrow to go to previous row the control box shows up.

How can I override this?.

Saravanan

A: 

Did you try setting ShowIcon to false?

Philip Wallace
Yes. It is set to false, but that does not prevent the control box from appearing.
SKG
A: 

How about this:

    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        if (keyData == Keys.Alt)
        {
            keyData = Keys.None;
        }
        return base.ProcessCmdKey(ref msg, keyData);
    }
Ken
+1  A: 

@Ken: I tried your code and focus was still going to Control Box for some reason. Tweaked it a bit and worked perfectly for my needs.

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 { 
   if (keyData == (Keys.RButton | Keys.ShiftKey | Keys.Alt))
         { return true; }
    return base.ProcessCmdKey(ref msg, keyData); 
  }
SKG