【问题标题】:Overlays in windows appsWindows 应用程序中的叠加层
【发布时间】:2009-09-01 22:21:16
【问题描述】:

有什么好的网站可以学习为 Windows 应用程序创建叠加层?当我试图理解基本概念时,欢迎阅读书籍或其他资源。 具体来说,如果我有一个显示视频的应用程序,我该如何添加覆盖层,例如人名或建筑物的 gps 坐标。

感谢您的宝贵时间。

【问题讨论】:

    标签: c#


    【解决方案1】:

    您必须先覆盖 WinForm 的 CreateParams:

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= Win32.WS_EX_LAYERED; //Make this form a layered window
            return cp;
        }
    }
    

    然后,每当您需要刷新窗口时,都需要调用UpdateLayeredWindow API。

    [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
    public static extern Bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, int crKey, ref BLENDFUNCTION pblend, int dwFlags);
    

    请参阅此Code Project Article 了解更多信息。

    【讨论】:

    • 谢谢。这似乎符合我的要求。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-29
    • 1970-01-01
    • 1970-01-01
    • 2017-04-20
    • 2015-01-20
    • 1970-01-01
    相关资源
    最近更新 更多