tags:

views:

232

answers:

4

Any tips on how to simulate the minimize button & behaviour

UPDATE - the minimize button needs to be on the caption bar as screen real estate is @ a premium

A: 

From within your window make a button that has the code:

this.WindowState = FormWindowState.Minimized;
Brian R. Bondy
thanks, updated the question, looking for tips on adding a minimize glyph to the caption
Kumar
A: 

I don't think you can, and I don't think you want to. Windows set to SizableToolWindow or FixedToolWindow are not shown in the taskbar, so once you'd minimized it there would be no way for a user to restore it. This is why there's no minimize button on a tool window.

What you probably want to do here is use a FixedDialog window, with its MaximizeBox property set to false. This form can be minimized and restored, but not maximized or resized in any way (and also doesn't have an icon, if that matters).

MusiGenesis
@AMissico: I may be losing my mind, but the title of the question is "minimize button for winforms form with sizabletoolwindow style".
MusiGenesis
@MusiGenesis: No, it was me. I was tired and in a hurry.
AMissico
@MusiGenesis: there's another way to bring up the form, and no, it's not on the taskbar
Kumar
FixedDialog won't work
Kumar
@Kumar: I said there's no way for a *user* to restore it. You can always restore it in code, but because the toolwindow doesn't show up in the taskbar, minimizing it and restoring won't look any different than making it invisible and then visible would.
MusiGenesis
Trying to manually draw a button on top of the caption bar is going to be a huge PITA (if it's even possible at all). Your best bet is probably going to be to make the form borderless and draw *everything* yourself.
MusiGenesis
Kumar
+5  A: 

Probably the best you are going to get on this is to follow what some others have done and tweak it as you need to. This question has been asked before and there are some good starting points here. The basic process is, you need to override WndProc to catch the message when the title bar is drawn, moved etc. Then you can inject your own paint method there. The real trouble you are going to have is all the code you will need to write to make your custom button match the current windows theme. In the end, you really are better off rethinking your form design to include the functionality elsewhere.

Jason Webb
A: 

i suggest you the way descriped by BigJason and to solve the issue with the drawing with the controlrenderer, that would draw the correct windowstheme button.

public static void DrawCaptionButton(Graphics graphics, int x, int y, int width, int height, CaptionButton button, ButtonState state); Declaring Type: System.Windows.Forms.ControlPaint Assembly: System.Windows.Forms, Version=2.0.0.0

Jack