Search code examples
c++windowswinapigdi

Transparent window on top of immersive full-screen mode


I am trying to draw on top of another process while it is in immersive full-screen mode. I know this is possible using GDI and I have 2 questions:

  1. Is it possible using a top-level transparent window ? (on top of the immersive process)
  2. Is there a higher level API witch I can use instead of GDI?

Thank you :)


Solution

  • In Windows, you have two possibilities for creating a fullscreen window:

    1. A full-screen application with exclusive drawing rights to the display.
    2. A borderless window that extends to the full desktop resolution.

    The first option allows you to change display properties like resolution, bit depth and refresh rate, while the second option is bound to use the same options here as a normal (windowed) desktop application.

    Overlaying a fullscreen window with a top-level window is only possible if the fullscreen application is implemented with option 2. In that case however, any code that is able to create a transparent top-level window will do (be it pure WinAPI/GDI, or something more sophisticated, like Qt).

    With option 1, as the description suggests, the fullscreen application has exclusive drawing rights to the display. Attempting to bring another window in front of it will either minimize the fullscreen application or force it into windowed mode.

    There are some hacks how you can still get an overlay in this case, but they are rather invasive. For example, with a fullscreen application based on D3D, you can hook into D3D's Present routine and have D3D draw your overlay before displaying the back buffer. The important point here is that the code for drawing the overlay is executed from within the process of the fullscreen application, as that is the only process that is allowed draw to the screen at that point.

    Note that some applications (in particular video games protected by anti-cheat software) do not like it very much if you inject code into the process this way.

    Note that the Win API also provides an interface for so called hardware overlays, which allow drawing on top of exclusive fullscreen applications. Unfortunately, this mechanism is not widely supported on consumer hardware and might not work depending on which graphics card you are trying to run it on.