Windows Develop Bookmark and Share   
 index > Windows Forms General > Minimize to Tray Window Form button.
 

Minimize to Tray Window Form button.

Hello.
How easy will it be to add a Minimize to Tray button beside the Minimize button on a Window Form? this was a big problem with XP cause the classic theme would look fine but then the XP theme was all weird looking the minimize to tray buttont that is... How come Microsoft hasnt added the Minimize to Tray button on Window Forms like Messenger im talking about the button with a square dot that communicates minimize to system tray... I hate putting this feature in menus or sub it with Minimize or Close button... its to WEIRD dosnt communicate please let it be easy to add this button to the Main Window Forms
VistaGuy  Wednesday, November 30, 2005 9:17 PM
Its hard, you have to handle WM_NCPAINT and WM_NCHITTEST.
JFo - MSFT  Thursday, December 01, 2005 3:02 AM
Its hard, you have to handle WM_NCPAINT and WM_NCHITTEST.
JFo - MSFT  Thursday, December 01, 2005 3:02 AM

I find this is the best approach.

protected override void WndProc(ref Message m)
{
    const UInt32 WM_SYSCOMMAND = 0x112;
    const UInt32 SC_MINIMIZE = 0xF020;

    if ((m.Msg == WM_SYSCOMMAND) && ((UInt32)m.WParam == SC_MINIMIZE))
    {
        this.Hide();
        return;
    }

    base.WndProc(ref m);
}

private void notifyIcon_DoubleClick(object sender, EventArgs e)
{
    this.Show();
    this.Activate();
}

r3n  Saturday, November 25, 2006 4:50 PM
The caption bar is part of the non-client area of the window which is handled by Windows, so it isn't easy to add a button there. I had to draw the button by myself and capture various mouse events to clone the behaviour of the other buttons (this button behaves exactly like the others do, or at least it should do Smile.....
Deezery  Saturday, July 05, 2008 10:23 PM

You can use google to search for other answers

Custom Search

More Threads

• Multi thread
• TableLayoutPanel - problem
• Panel Events & SplitContainers
• Form Design
• Splash Screen
• 2 Forms. this->Close(); problem.
• ListView, TreeView, Splitter Issue
• How do I host Windows Forms Controls which are having dependencies in Internet Explorer?
• how to move control at runtime
• Flash Design