如何在所有窗口之上显示半透明窗口? [英] How to show semitransparent window above all windows?

查看:284
本文介绍了如何在所有窗口之上显示半透明窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在所有窗口之上显示半透明窗口?并在此窗口中加载一些信息:image / text / button?我需要在windows / linux(或至少窗口)上显示一些半透明区域,在所有的桌面上,在该区域的中心,我需要显示一些图像与文本。但是,所有这一切,它不必关注当前的工作应用程序。它将被自动隐藏。
请参见图像:正常的desctop和我想要的半透明窗口。
谢谢。

How to show semitransparent window above all windows? And to load some info in this window: image/text/button? I need to show some semitransparent region above all desctop table in windows/linux (or at least windows), and in the center of that region I need to show some image with text. But with all that it must not take focus of the current working application. It will be hidden automatically. Please see images: normal desctop and the semitransparent window I want to make. Thanks.

推荐答案

在C#中,这是你所需要的代码:

In C#, this is the code that does what you need:

注意:它不会专注于启动,

Note: It does not steel focus on startup and it does not steel focus when clicking on it.

public static class ExtendedWindowStyles
{

    public static readonly Int32

    WS_EX_ACCEPTFILES = 0x00000010,

    WS_EX_APPWINDOW = 0x00040000,

    WS_EX_CLIENTEDGE = 0x00000200,

    WS_EX_COMPOSITED = 0x02000000,

    WS_EX_CONTEXTHELP = 0x00000400,

    WS_EX_CONTROLPARENT = 0x00010000,

    WS_EX_DLGMODALFRAME = 0x00000001,

    WS_EX_LAYERED = 0x00080000,

    WS_EX_LAYOUTRTL = 0x00400000,

    WS_EX_LEFT = 0x00000000,

    WS_EX_LEFTSCROLLBAR = 0x00004000,

    WS_EX_LTRREADING = 0x00000000,

    WS_EX_MDICHILD = 0x00000040,

    WS_EX_NOACTIVATE = 0x08000000,

    WS_EX_NOINHERITLAYOUT = 0x00100000,

    WS_EX_NOPARENTNOTIFY = 0x00000004,

    WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,

    WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST,

    WS_EX_RIGHT = 0x00001000,

    WS_EX_RIGHTSCROLLBAR = 0x00000000,

    WS_EX_RTLREADING = 0x00002000,

    WS_EX_STATICEDGE = 0x00020000,

    WS_EX_TOOLWINDOW = 0x00000080,

    WS_EX_TOPMOST = 0x00000008,

    WS_EX_TRANSPARENT = 0x00000020,

    WS_EX_WINDOWEDGE = 0x00000100;

}

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        this.TopMost = true;
    }

    protected override bool ShowWithoutActivation
    {
        get
        {
            return true;
        }
    }
    protected override CreateParams CreateParams
    {
        get
        {
            var currentParameters = base.CreateParams;

            currentParameters.ExStyle |= (int)(ExtendedWindowStyles.WS_EX_NOACTIVATE | ExtendedWindowStyles.WS_EX_TOOLWINDOW);

            return currentParameters;
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
        this.ClientSize = Screen.PrimaryScreen.Bounds.Size;
        this.Left = 0;
        this.Top = 0;
        this.Opacity = 0.5;
    }
}

(图片,标签等)。

您只需通过使用form.ShowDialog();从应用程序代码中弹出此表单。如果你想从任何地方弹出这个窗体,使它成为一个可执行文件,并在需要时运行它。

You just have to pop this form from your application code by using form.ShowDialog ();. If you want to pop this form from whatever place, make it an executable and run it whenever you need it.

这篇关于如何在所有窗口之上显示半透明窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆