Any tips on how to simulate the minimize button & be开发者_运维问答haviour
UPDATE - the minimize button needs to be on the caption bar as screen real estate is @ a premium
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.
From within your window make a button that has the code:
this.WindowState = FormWindowState.Minimized;
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).
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
精彩评论