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

Kumar
  • 10,997
  • 13
  • 84
  • 134

4 Answers4

6

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.

Community
  • 1
  • 1
Jason Webb
  • 7,938
  • 9
  • 40
  • 49
0

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

this.WindowState = FormWindowState.Minimized;
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
  • thanks, updated the question, looking for tips on adding a minimize glyph to the caption – Kumar Mar 31 '10 at 13:14
0

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
  • 74,184
  • 40
  • 190
  • 334
  • @AMissico: I may be losing my mind, but the title of the question is "minimize button for winforms form with sizabletoolwindow style". – MusiGenesis Mar 31 '10 at 02:02
  • @MusiGenesis: No, it was me. I was tired and in a hurry. – AMissico Mar 31 '10 at 03:43
  • @MusiGenesis: there's another way to bring up the form, and no, it's not on the taskbar – Kumar Mar 31 '10 at 13:13
  • @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 Mar 31 '10 at 17:24
  • 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 Mar 31 '10 at 17:25
  • @MusiGenesis - The user will be able to restore it using another paradigm than using the taskbar along with the ability to change the formborderstyle from regular to fixedtoolwindow @runtime among other things. Re: buttons on the caption - I have seen it done before though obviously i can't recall when/where & that's why i'm here. drawing everything yourself would be a bigger PITA than just adding the button or even overlaying it on top of it which would be my preference. BTW i like the musigenesis s/w concept and will try it out @home ! – Kumar Mar 31 '10 at 17:43
0

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
  • 292
  • 1
  • 5