如何在标题栏上仅显示最小化和关闭按钮
我只想在标题栏上显示“最小化”和“关闭”按钮,而不在 WinForm 应用程序中使用 C#.net 显示“最大化”按钮。如果我设置 this.MaximizeBox = false,则最大化按钮仍会显示,但会被禁用。 任何帮助将不胜感激。请向我提供您的优秀想法,
提前致谢。
I only want to display the Minimize and Close buttons on the caption bar, without the Maximize button using C#.net in WinForm Application. If I put this.MaximizeBox = false, the Maximize button is still displayed although it will be disabled.
Any help will be appreciated. Please Provide me your excellent ideas
Thanks in Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要做的是绘制自己的镀铬窗户。请参阅此问题了解如何执行此操作:
Custom titlebars/chrome in a WinForms app
What you need to do is paint your own window chrome. See this SO question for how to do so:
Custom titlebars/chrome in a WinForms app
如果您不介意丢失最小化按钮,则可以使用 FormBorderStyle 到固定工具窗口或可调整工具窗口的形式。
不过,这种方法有一些副作用(来自 MSDN):
您可以将窗体上的控制框属性设置为 false(但随后您将丢失关闭按钮和最小化按钮)。
看起来您还应该能够使用 Windows API(在此链接中,该人隐藏了 wpf 应用程序的关闭按钮,但我认为您可以重新调整它的用途)http:// winsharp93.wordpress.com/2009/07/21/wpf-hide-the-window-buttons-minimize-restore-and-close-and-the-icon-of-a-window/
If you don't mind losing the minimize button, you could use the forms FormBorderStyle to FixedToolWindow or SizableToolWindow.
There are some side effects to this approach though (from MSDN):
You could set the control box property on the form to false (but then you lose the close button as well as the minimize button).
It looks like you should also be able to use the windows API (in this link the guy is hiding the close button for a wpf app, but I would think you could repurpose it) http://winsharp93.wordpress.com/2009/07/21/wpf-hide-the-window-buttons-minimize-restore-and-close-and-the-icon-of-a-window/