Sorashi
Sorashi

Reputation: 931

Own form border style

I always thought that form borders that use programs like iTunes or Visual Studio 2012 are done without border style and buttons as close button are drawn as images.

Visual Studio 2012 Musicjet

However once my Visual Studio wasn't responding and the border changed to the basic Windows border.

Windows

How can I get own form border? Is it possible in C#?

Upvotes: 6

Views: 2336

Answers (2)

danielcooperxyz
danielcooperxyz

Reputation: 999

Further to @Hans' post:

Using WPF you can set the windowstyle to none like this:

<Window WindowStyle="None">

Then you can implement your own buttons.

Upvotes: 0

Hans Passant
Hans Passant

Reputation: 941407

You are seeing the "ghost window", a window that the Windows window manager creates to replace the dead window. You see "Not Responding" in the title bar. That window isn't going to have to same custom styling of course, there's no way Windows knows how to do that properly.

You can use the Spy++ utility to look at the window properties of another app. VS2012 does in fact use a regular window style with a title bar. How they customized it is a well kept secret, I suspect they intercept WM_NCPAINT, a fairly difficult message to implement yourself. Using a borderless window is definitely easier.

Upvotes: 3

Related Questions