Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Drawing directly to the screen (like an overlay)

Many laptops nowadays have FN hot keys to change volume, brightness, etc. and usually display a visual cue that is rendered on the screen completely above the operating system. For new Windows 8/8.1 systems this visual even appears outside of the desktop in the metro side. They cannot be drawing inside of a borderless window otherwise it wouldn't show up over the metro interface.

I have tried researching whether DirectX can draw directly to the screen but it doesn't appear it can. I don't even know if I should look into OpenGL... ?

I had some success using GDI; specifically the GetDC function with the parameter NULL to grab the screen device.

#include <Windows.h>

int main() {
    const HDC dc = GetDC(NULL);
    while (1) {
        Rectangle(dc, 100, 100, 500, 500);
    }
}

However, this requires re-rendering everything repeatedly because my region of the screen can be overwritten by other windows changing in the background. And even with it re-rendering in a loop, there is massive screen flicker.

How do the OEM manufacturers of these laptops achieve this?

Thanks.

like image 531
Bradley Odell Avatar asked Jul 29 '14 21:07

Bradley Odell


1 Answers

It looks like these are borderless windows. For example, have a look at the task switcher window:

Borderless Window

Related question: Windows 8 Layered Windows Over Metro Apps

If you want a window on top of Metro, you need it to declare accessibility.

like image 107
MrAnno Avatar answered Oct 17 '22 00:10

MrAnno