C# - Standalone ContextMenuStrip - Some frustrations

582 views Asked by At

I'm trying to make a program that basically is a ContextMenuStrip, where users can add their own shortcuts and so on and access the menu by pressing a hotkey combination.

The way I make the menu appear is by giving the main form 0% opacity, but if there is another way, please let me know.

My wish is to make something like this, just a lot more customizable and user-friendly: http://www.bullzip.com/products/exm/info.php

So far I've had a couple of problems: - When the menu is first shown, everything works fine, but when I try pressing the hotkey again, the menu appears, but so does a "blank" window in the taskbar. - Again, when the menu is first shown, everything is fine, but when clicking anywhere else than on the menu, it won't close again. The only way to close it, is by selecting something from the menu.

Hopefully some of you can point me in the direction of a solution :)

Thank you in advance!

1

There are 1 answers

2
WillDud On
Form.ShowInTaskbar = false;

Form.WindowState = FormWindowState.Minimized;

This should hide the form for you.

Then use the following to trap key presses.

protected override bool ProcessCmdKey(ref Meassage msg, Keys keyData)
{
    if(keydata == whatever)
    {
        contextmenustrip.Show();
    }    

    return true; //false if you want to suppress the key press.
}