ranja
ranja

Reputation:

Overlays in windows apps

What's a good site to learn about creating overlays for windows applications? Books or other resources would be welcome as I am trying to understand the basic concepts. Specifically, if I have an application that diplays a video, how do I add overlay layer(s) with things like the person's name or a building's gps coordinates.

Thanks for your time.

Upvotes: 0

Views: 440

Answers (1)

Pierre-Alain Vigeant
Pierre-Alain Vigeant

Reputation: 23083

You have to override the CreateParams of your WinForm first:

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

Then, whenever you need to refresh your window, you need to call the 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);

See this Code Project Article to learn more.

Upvotes: 1

Related Questions