I am trying to paint in the non-client area, to produce a custom "skin". Though I can trap the WM_NCPAINT
message, I cannot get any of the drawing functions to work. Here is a test code, to draw a small, red rectangle in the NC area. The coordinates in this test are hard-coded, to rule-out the possibility of a bad variable (the upper-left corner of the window is at screen coords 100, 100):
case WM_NCPAINT:
{
HDC hdc = GetWindowDC(hwnd);
auto ncpResult = DefWindowProc(hwnd, WM_NCPAINT, wParam, lParam);
HRGN rL = CreateRectRgn(401, 101, 410, 110);
FillRgn(hdc, rL, CreateSolidBrush(0x000000FF));
DeleteObject(rL);
ReleaseDC(hwnd, hdc);
return ncpResult;
}
I have also tried to get the DC using this method:
HDC hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW | DCX_INTERSECTRGN);
In addition, I have tried FillRect()
, as well as the MoveToEx()
and LineTo()
combination. None of these have any effect.
I am using Visual Studio 2019, on Windows 7.
User contributions licensed under CC BY-SA 3.0