Xavier Wang
Xavier Wang

Reputation: 31

How to hook the repaint event of screen (make a middle level of screen) on Windows?

I'm wondering how to render Screen as a middle level.

that is, I can produce the screen HDC after every repaint of screen, and before the screen is actually display on monitor.

for example, the magnifier utility of Window 7. you can see the content under the magnifier window, how does it made?

Upvotes: 1

Views: 312

Answers (2)

IInspectable
IInspectable

Reputation: 51345

As I understand the question, the specific issue is in capturing the screen while treating the capturing application as if it were transparent.

A solution for this was introduced in Windows 10 Version 2004 via the WDA_EXCLUDEFROMCAPTURE constant to the SetWindowDisplayAffinity() API. The effect of setting this on a window is that screen captures (using BitBlt() or Windows.Graphics.Capture) will contain whatever is underneath this window.

No hooking into the desktop compositor is required to make this work.

Upvotes: 0

Sam Ginrich
Sam Ginrich

Reputation: 841

There are three steps

  1. Identify visible windows using EnumWindows
  2. Listen on window creation to update the set of visible windows, Shell Hook
  3. Listen on WM_PAINT messages with a Message Hook, where the Desktop has a dedicated handle

Upvotes: 0

Related Questions