如何删除系统菜单 [英] How to remove System Menu
本文介绍了如何删除系统菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨...
我想从标题栏中删除系统菜单
恢复
最大化
最小化
移动
但是我已经通过使用系统API来做到这一点,user32.dll的功能
Hi...
I want to remove system menu from the title bar
Restore
Maximize
Minimize
Move
but I have done it by using the system API ,the function of the user32.dll
[DllImport("user32.dll")]
public static extern bool RemoveMenu(IntPtr hMenu, Int32 wPosition, Int32 wFlags);
但是使用此功能时,相对功能也被禁用.
我想删除系统菜单,但功能应保留.
But using this function the relative functionality is also disabled.
I want to remove the system menu but the functionality should remain.
推荐答案
我认为使用P/Invoke的解决方案很丑陋,但它们应该可以工作:
^ ],
^ ].
我可能更喜欢仅.NET的解决方法.
您可以通过为属性System.Windows.Window.WindowStyle
分配不同的值来使用不同的Windows样式.您也可以在XAML的顶级标签<Window>
中进行此操作.使用System.Windows.WindowStyle.ToolWindow
的值.参见:
http://msdn.microsoft.com/en-us/library/system. windows.window.windowstyle.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.windows. windowstyle.aspx [ ^ ].
或者,您可以使用System.Windows.WindowStyle.None
,但是在这种情况下,您将根本没有任何非客户区域,没有标题栏和按钮,也没有任何内容.此样式通常用于开发非矩形形状的窗户以及其他高度自定义外观的情况.在某些应用程序中,非客户端区域缺少的控件元素(例如关闭,最小化/还原按钮,系统菜单等)可以使用WPF控件(无论是否自定义)在客户端区域中进行简单模拟.
注意第二种选择;它看起来并不那么麻烦.这仅仅是外观定制的最高级别.这样的设计完全摆脱了对Windows的依赖,并呈现了纯的仅WPF" UI.对于某些(也许是非常奇特的)UI类型,这是最好的.
—SA
I think the solutions using P/Invoke are ugly, but they should work:
http://blogs.msdn.com/b/wpfsdk/archive/2007/08/02/a-wpf-window-without-an-window-icon-the-thing-you-click-to-get-the-system-menu.aspx[^],
http://winsharp93.wordpress.com/2009/07/21/wpf-hide-the-window-buttons-minimize-restore-and-close-and-the-icon-of-a-window/[^].
I would probably prefer a .NET-only work-around.
You can use different windows style by assigning different value to the propertySystem.Windows.Window.WindowStyle
. You can also do it in XAML, in the top-level tag<Window>
. Use the value ofSystem.Windows.WindowStyle.ToolWindow
. See:
http://msdn.microsoft.com/en-us/library/system.windows.window.windowstyle.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.windowstyle.aspx[^].
Alternatively, you can useSystem.Windows.WindowStyle.None
, but in this case you won''t have any non-client areas at all, not a title bar and buttons, nothing. This style is usually used to develop windows with non-rectangular shapes and other cases of highly customized appearance. In certain applications, the missing control elements of non-client area (such as close, minimize/restore buttons, system menu, etc.) are simply simulated in the client area using WPF controls, custom or not.
Pay attention for this second option; it is not so cumbersome as it might seem. This is just the maximum level of customization of appearance possible; such design totally goes away from dependency on Windows and presents pure "WPF-only" UI. For certain (maybe rather exotic) types of UI, this is the very best.
—SA
这篇关于如何删除系统菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文