如何在标题栏上仅显示最小化和关闭按钮

发布于 2024-10-08 22:37:26 字数 158 浏览 1 评论 0原文

我只想在标题栏上显示“最小化”和“关闭”按钮,而不在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

守望孤独 2024-10-15 22:37:26

您需要做的是绘制自己的镀铬窗户。请参阅此问题了解如何执行此操作:

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

你的往事 2024-10-15 22:37:26

如果您不介意丢失最小化按钮,则可以使用 FormBorderStyle 到固定工具窗口或可调整工具窗口的形式。
不过,这种方法有一些副作用(来自 MSDN):

FixedToolWindow:不可调整大小的工具窗口边框。工具窗口不会出现在任务栏或用户按 ALT+TAB 时出现的窗口中。尽管指定FixedToolWindow 的窗体通常不会显示在任务栏中,但您还必须确保ShowInTaskbar 属性设置为false,因为它的默认值为true。

SizedToolWindow:可调整大小的工具窗口边框。工具窗口不会出现在任务栏中或用户按 ALT+TAB 时出现的窗口中。

您可以将窗体上的控制框属性设置为 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):

FixedToolWindow: A tool window border that is not resizable. A tool window does not appear in the taskbar or in the window that appears when the user presses ALT+TAB. Although forms that specify FixedToolWindow typically are not shown in the taskbar, you must also ensure that the ShowInTaskbar property is set to false, since its default value is true.

SizableToolWindow: A resizable tool window border. A tool window does not appear in the taskbar or in the window that appears when the user presses ALT+TAB.

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文