tags:

views:

64

answers:

2

Tried the CreateParams override as suggested here, however, the taskbar button does not appear on initial load. The user has to activate another window, then re-activate the target window before the taskbar button appears.

Any reason why this is so? How do you workaround this?

+1  A: 

Try adding the WS_EX_APPWINDOW flag to the ExStyle property of CreateParams.

Windows is trying to guess whether your window should have a taskbar button by looking at the caption and other styles. The WS_EX_APPWINDOW makes it explict so Windows doesn't have to guess.

WS_EX_TOOLWINDOW makes it explicit that you should NOT have a taskbar button.

Edit: like this

protected override CreateParams CreateParams
{
    get
    {
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x0040000;   // add WS_EX_APPWINDOW 
        cp.Style   &= ~0x00C00000;  // remove WS_CAPTION
        return cp;
    }
}
John Knoeller
A: 
sjlewis
You are turning the flag off, you're supposed to turn it on. Use |= 0x40000.
Hans Passant
silly me.. thanks for pointing that out.
sjlewis