Mohit Deshpande
Mohit Deshpande

Reputation: 55247

Change the icon of the window of the minimize, close and maximize

Simple question. How can I change the icons of the close, minimize, maximize buttons. Can I do this in Winforms and WPF?

Upvotes: 2

Views: 7704

Answers (6)

Nir
Nir

Reputation: 29594

Doing this isn't difficult but it is a lot of work - you have to basically replace the window frame and handle everything yourself, there is a lot of functionality in the default window frame you have to rewrite - you also have to write different code for Vista/7 with Aero enabled.

In WPF you use the various techniques in http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx

In WinForms you use the same basic techniques but I don't know of a page that summarizes all the details like the link above.

Upvotes: 4

viky
viky

Reputation: 17689

In wpf, you can set WindowStyle="None" for your Window and then set a custom TitleBar for that, with minimize, maximize and close button. I have done this earlier. You need to do some event handling to perform minimize, maximize, close, drag etc.

Upvotes: 2

John Knoeller
John Knoeller

Reputation: 34188

These Icons, the caption, and the border on your window are all drawn while processing the WM_NCPAINT message. So, the way you take over drawing this is by handling this message.

But you don't have access to the state information about the icons (i.e. which button you should draw in it's pressed state because the user is currently clicking on it.). You dont even know where exactly the mouse handling code thinks these icons are.

So to take over non-client paint, you also need to take over non-client mouse handling, and the whole problem just snowballs until you've written thousands of lines of code and your window still doesn't behave quite right when the user tries to drag it, etc.

And that's in unmanaged code, in managed code (C#/.Net) this is even harder because you also have to do interop to get to some of the APIs you need to use.

So the answer is: Yes its possible, but its harder in WinForms and WPF than it is in C++, and those that have attempted it are all bald now.

Upvotes: 7

Gabriel McAdams
Gabriel McAdams

Reputation: 58293

If you want to control the look of those buttons, you'll have to create your own. This is one value of using Windows features to write windows applications (they come with a standard look and feel).

Upvotes: 0

Anvaka
Anvaka

Reputation: 15823

Yes, you have to create your own window style. Refer to FluidKit, GlassWindows for example.

Upvotes: 0

James Keesey
James Keesey

Reputation: 1217

The real answer is that you shouldn't do this. Users expect all applications to work and look the same. Making them try an figure out what spiffy new icon you use means minimize is likely to make them unhappy.

Upvotes: 5

Related Questions