views:

43

answers:

1

In Windows 7, the volume mixer windows has a specific style, with a thick, transparent border, but no title bar. How do i recreate that window style in a winforms window?

volume mixer

I tried setting Text to string.Empty, and ControlBox to false, which removes the titlebar, but then the border also disappears:

border disappears

+1  A: 
form.Text = string.Empty;
form.ControlBox = false;
form.FormBorderStyle = FormBorderStyle.SizableToolWindow;

For a fixed size window, you should still use FormBorderStyle.SizableToolWindow, but you can override the form's WndProc to ignore non-client hit tests (which are used to switch to the sizing cursors):

protected override void WndProc(ref Message message)
{
    const int WM_NCHITTEST = 0x0084;

    if (message.Msg == WM_NCHITTEST)
        return;

    base.WndProc(ref message);
}

If you want to really enforce the size, you could also set MinimumSize equal to MaximumSize on the form.

Chris Schmich
Nope, this removes the border completely
oɔɯǝɹ
@oɔɯǝɹ: form.FormBorderStyle = FormBorderStyle.SizableToolWindow seems to work correctly for me.
Merlyn Morgan-Graham
@oɔɯǝɹ: `FixedToolWindow` does remove the 3D border. See my updated answer for getting fixed-size behavior with the 3D border intact.
Chris Schmich
SizeableToolWindow does the trick, thanks!
oɔɯǝɹ