开发者

Overriding non-client window styles in Windows

I've noticed an increasing number of Windows applications that do not have the usual non-client window borders and maximize/minimize/close buttons. Examples include the Zune player software and the MetroTwit Twitter clie开发者_如何学运维nt app.

My question is: how does one do this without resorting to native API coding? Is it possible to create such applications using .Net (by overriding Form.OnPaint?) or WPF?

Suggestions and/or sample code snippets would be welcomed.


They all use the same approach, they simply create a window without a border and caption bar. Then draw their own, styling it the way they want to. It is easy to tell, the Close button in the upper right corner is always subtly off. Sometimes intentionally of course.

No native API coding is required to do this. But overriding WndProc() can be handy to recover some of the functionality that's lost when you omit the caption bar and a resizable border. Google WM_NCHITTEST to find sample code, there's plenty here as well.

In general, watch out doing this. These kind of custom styled windows are often featured in GUI Blooper lists. This one is my favorite example. On the same page, this one is a classic trap.


This is easy to do in .Net (don't know about WPF). Here's a code sample:

custom dialog with a text field in winmobile

It's for .Net CF, but it will work fine in a WinForms application - the only difference is that the border style property is called BorderStyle in one and FormBorderStyle in the other.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜