Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aero Glass borders on popup windows in C#

I would like to create pop-up windows (of a fixed size) like this:

pop-up windows

in my application using C#. I've looked into NativeWindow but I am not sure if this is the right way to do it. I want a window to behave exactly like the volume control or "connect to" window in Windows 7.

How can I accomplish this?

like image 272
zsalzbank Avatar asked May 12 '09 15:05

zsalzbank


1 Answers

Using WinForms, create a form and set the following:

Text = "";
FormBorderStyle = Sizable;
ControlBox = false;
MaximizeBox = false;
MinimizeBox = false;
ShowIcon = false;

Edit:

This does require the window be sizable, but you can cheat at that a little. Set the MinimumSize and MaximumSize to the desired size. This will prevent the user from resizing.

As Jeff suggested, you can also do this in CreateParams:

protected override CreateParams CreateParams
{
    get
    {
        CreateParams cp = base.CreateParams;
        unchecked
        {
            cp.Style |= (int)0x80000000;    // WS_POPUP
            cp.Style |= 0x40000;            // WS_THICKFRAME
        }
        return cp;
    }
}

In both cases, however, you'll still get a sizing cursor when you hover over the edges. I'm not sure how to prevent that from happening.

like image 163
Jon B Avatar answered Sep 25 '22 02:09

Jon B