如果我们使用< windowchrome.windowchrome>,请禁用contxtmenu。

编程入门 行业动态 更新时间:2024-10-19 12:43:26
本文介绍了如果我们使用< windowchrome.windowchrome>,请禁用contxtmenu。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果我使用WindowChrome.WindowChrome样式,我无法禁用。请让我知道您的输入以解决此问题。没有WindowChrome,我可以使用相同的代码禁用上下文菜单。 我尝试过:

I am unable to disable if I use WindowChrome.WindowChrome style. Please let me know your input to resolve this problem. Without WindowChrome, I am able to disable context menu with the same piece of code. What I have tried:

<Window x:Class="ConextMenu_Sample.MainWindow" xmlns="schemas.microsoft/winfx/2006/xaml/presentation" xmlns:x="schemas.microsoft/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" WindowStyle="None"> <WindowChrome.WindowChrome> <WindowChrome CaptionHeight="35" CornerRadius="0" ResizeBorderThickness="5" UseAeroCaptionButtons="False" /> </WindowChrome.WindowChrome> <Window.Resources> </Window.Resources> <Grid> </Grid> </Window> public partial class MainWindow : Window { private const uint WP_SYSTEMMENU = 0x02; private const uint WM_SYSTEMMENU = 0xa4; public MainWindow() { InitializeComponent(); Loaded += OnLoaded; } private void OnLoaded(object sender, RoutedEventArgs e) { IntPtr windIntPtr = new WindowInteropHelper(this).Handle; HwndSource hwndSource = HwndSource.FromHwnd(windIntPtr); hwndSource.AddHook(new HwndSourceHook(WndProc)); } private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled) { if ((msg == WM_SYSTEMMENU) && (wparam.ToInt32() == WP_SYSTEMMENU)) { handled = true; } return IntPtr.Zero; } }

推荐答案

此Google搜索: WPF禁用窗口上下文菜单 - Google搜索 [ ^ ]为您提供了许多解决方案,包括: a href =stackoverflow/a/14572330> wpf - 禁用整个上下文菜单 - 堆栈溢出 [ ^ ] This Google search: wpf disable window context menu - Google Search[^] has many solutions for you including this one: wpf - Disable the whole Context Menu - Stack Overflow[^]

更多推荐

如果我们使用&lt; windowchrome.windowchrome&gt;,请禁用contxtmenu。

本文发布于:2023-11-11 23:01:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579790.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:lt   amp   windowchrome   contxtmenu   gt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!