Im trying to create double buffered gdi overlay over desktop but all what i get is black screen with red line
HDC hdc = GetDC(0);
HDC mem_handle = CreateCompatibleDC(hdc);
HBITMAP bitmap_hndl = CreateCompatibleBitmap(hdc, 1920, 1080);
HBITMAP old0 = (HBITMAP)SelectObject(mem_handle, bitmap_hndl);
HPEN pen = CreatePen(PS_SOLID, 5, RGB(255, 0, 0));
HGDIOBJ oldpen = SelectObject(mem_handle, pen);
POINT Dots[2];
Dots[0] = { 500, 500 };
Dots[1] = { 200, 200 };
DWORD NumDots = 2;
PolyPolyline(mem_handle, Dots, &NumDots, 1ull);
BitBlt(hdc, 0, 0, 1920, 1080, mem_handle, 0, 0, SRCCOPY | CAPTUREBLT);
SelectObject(mem_handle, oldpen);
SelectObject(mem_handle, old0);
DeleteObject(pen);
DeleteObject(bitmap_hndl);
DeleteDC(mem_handle);
ReleaseDC(0, hdc);
Im tried to use alphabland and transparentblt but nothing changed
You can't create a "gdi overlay over the desktop" by just painting to the screen's device context. Painting to
GetDC(NULL)will, maybe, get some pixels displayed for a few milliseconds before something else paints over them.Windows is called "Windows" for a reason. If you want something to persist on the screen you need to paint it in the WM_PAINT handler of a window you create. Otherwise, you can't control when what you paint will be overwritten.