Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
临时看穿wpf应用程序-à;la Visual Studio Ctrl键用于工具提示_Wpf_Transparency - Fatal编程技术网

临时看穿wpf应用程序-à;la Visual Studio Ctrl键用于工具提示

临时看穿wpf应用程序-à;la Visual Studio Ctrl键用于工具提示,wpf,transparency,Wpf,Transparency,上下文:我正在开发一个WPF应用程序,在这个应用程序中,用户经常需要从其他程序手动转录一些数据。由于没有双监视器,这需要大量的Alt选项卡 我想,拥有与VisualStudio中工具提示相同的功能会非常好,在这里,您可以按Ctrl键使它们略微透明 我遇到的“问题”是,只有当您的窗口允许透明度时,您才能(有效地)使用透明度,而反过来,只有当WindowStyle=None时,才可能使用透明度。我真的不想陷入在我的应用程序上重新创建标题栏等的所有复杂问题 是否有合适的替代方案?通过一点Win32 I

上下文:我正在开发一个WPF应用程序,在这个应用程序中,用户经常需要从其他程序手动转录一些数据。由于没有双监视器,这需要大量的Alt选项卡

我想,拥有与VisualStudio中工具提示相同的功能会非常好,在这里,您可以按Ctrl键使它们略微透明

我遇到的“问题”是,只有当您的窗口
允许透明度时,您才能(有效地)使用透明度,而反过来,只有当
WindowStyle=None
时,才可能使用透明度。我真的不想陷入在我的应用程序上重新创建标题栏等的所有复杂问题


是否有合适的替代方案?

通过一点Win32 Interop,您可以获得窗口的一个窗口,并使用CreateRgn为您的窗口定义一个剪裁区域,这将根据需要呈现窗口的任何部分“透明”。它还将修改命中测试,因此,该窗口不仅是“透明”的,而且是“点击通过”

下面是我最喜欢的一个项目中的一些内容,这消除了窗口的客户端区域。这里的一些代码可能是特定于WPF的,但最终这里显示的Win32 API自90年代初就出现了

    [DllImport("gdi32.dll")]
    internal static extern IntPtr CreateRectRgnIndirect([In] ref Mubox.Win32.Windows.RECT lprc);

    [DllImport("gdi32.dll")]
    internal static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);

    [DllImport("user32.dll")]
    internal static extern int SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool bRedraw);

    [DllImport("gdi32.dll")]
    internal static extern int CombineRgn(IntPtr hrgnDest, IntPtr hrgnSrc1, IntPtr hrgnSrc2, CombineRgnStyles fnCombineMode);

    public enum CombineRgnStyles : int
    {
        RGN_AND = 1,
        RGN_OR = 2,
        RGN_XOR = 3,
        RGN_DIFF = 4,
        RGN_COPY = 5,
        RGN_MIN = RGN_AND,
        RGN_MAX = RGN_COPY
    }

    #endregion

                    IntPtr windowRegion = Control.Windows.CreateRectRgn(0, 0, parkingWindowRect.Width, parkingWindowRect.Height);
                    Mubox.Win32.Windows.RECT clipRect = new Mubox.Win32.Windows.RECT();

                        Mubox.Win32.Windows.GetClientRect(this.Handle, out clipRect);
                        clipRect.Left = (parkingWindowRect.Width - clipRect.Width) / 2;
                        clipRect.Right += clipRect.Left;
                        clipRect.Top = (parkingWindowRect.Height - clipRect.Height) - clipRect.Left;
                        clipRect.Bottom = parkingWindowRect.Height - clipRect.Left;


                    IntPtr clipRegion = Control.Windows.CreateRectRgnIndirect(ref clipRect);
                    Control.Windows.CombineRgn(windowRegion, windowRegion, clipRegion, Windows.CombineRgnStyles.RGN_XOR);
                    Control.Windows.DeleteObject(clipRegion);
                    Control.Windows.SetWindowRgn(this.Handle, windowRegion, true);

我想你的意思是特定于WinForms,什么是Mubox?Google找到的“Mubox.Win32.Windows”的唯一参考是以下页面:(好的,我设法解决了我必须滚动我自己的RECT结构。据我所知,我在这里只能选择完全透明,没有不透明?Mubox是@,上面提供的代码不是公共/开源版本的一部分。使用区域可以让你定义一个非矩形的剪切区域,如果你喜欢的话。剪切不同作为透明度,也就是说,您不能定义不透明度级别。您可以定义一个小到1像素或大到窗口的区域。我使用它来阻止窗口的客户端区域,我将其用作外部/第三方应用程序的控制框(例如,伪造另一个不提供任何NC控制的应用程序的NC区域。)已经有一段时间了,但是,你确认这对你有效吗?