Window.xmal代码:
<Window x:Class="Test.Class1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
title="Right Click To Close" Height="300" Width="300"
WindowStyle="None" AllowsTransparency="True" MouseRightButtonUp="WindowClicked"
Background="{x:Null}"
>
<Grid MouseRightButtonDown="WindowClicked">
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=Title}"
FontSize="18" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="20"
MouseLeftButtonDown="DragWindow" FontFamily="Impact" Foreground="Red"/>
<Viewbox Stretch="Uniform" MouseLeftButtonDown="DragWindow">
<蚂茄Path Fill="#80D0E0FF" Stroke="Red" StrokeThickness="0" HorizontalAlignment="Center" VerticalAlignment="Center"
Data="M79,3L65,82 17,91 50,138 96,157 104,192 175,154 190,167 218,78 156,76 157,9 111,39z"/>
</Viewbox>
</Grid>
</Window>
Window.xmal.cs 代码空物闷:
using System
using System.Collections.Generic
using System.Text
using System.Windows
using System.Windows.Controls
using System.Windows.Data
using System.Windows.Documents
using System.Windows.Input
using System.Windows.Media
using System.Windows.Media.Imaging
using System.Windows.Shapes
namespace Test
{
public partial class Class1 : System.Windows.Window
{
public Class1()
{
InitializeComponent()
}
public void DragWindow(object sender, MouseButtonEventArgs args)
{
DragMove()
}
public void WindowClicked(object sender, MouseButtonEventArgs args)
{
Close()
}
}
}
在windows *** 作系统,扒绝则有一个dll专门负宏拿责鼠标穿透事件,穿透本质只针对设置色值区域,只春棚要色值对得上的区域都能穿透,鼠标能直接 *** 作覆盖的东西,色值对不上的区域正常显示。您好,很高兴为您解答:让父窗体响应鼠标事件
C/C++ code
setAttribute(Qt::WA_TransparentForMouseEvents,true)
setWindowFlags(Qt::FramelessWindowHint)
setAttribute(Qt::WA_TranslucentBackground)
以上就嫌租可以实现穿透。
如果我谨袜的回答没帮芹晌兆助到您,请继续追问。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)