I am at the moment handling the WM_NCPAINT for my app. I painted a section of the top non-client area using the return value of GetWindowRect but the coordinates fell inside my applications client area. I decided to Use GetMenuBarInfo to get the menubar coordinates but the experience was the same. Using the update region made avilable by wParam is about the same result. How can I remedy these?
The relevant codes are shown below.
In the codes below, I expect GetWindowRect to return the coordinates of the window in question such that when I replace the RECT.bottom value of the returned value by 100, a band of colour starting from the top of the window and down until 100 pixels below is reached is drawn. I do not expect the band of colour to fall within the client rect not to talk of starting in it, but what I see is a displaced colour band stating at a distance in the client rect,
hdc = GetWindowDC(hWnd);
HBRUSH hBrush = CreateSolidBrush(AppColor);
RECT rcWindow;
GetWindowRect(hWnd,&rcWindow);
rcWindow.bottom = 100;
RECT rcFill{ rcWindow };
FillRect(hdc, &rcFill, hBrush);
DeleteObject(hBrush);
ReleaseDC(hWnd,hdc);
In the code below, I expect the menu bar to be filled with the specified colour, but what I get is a band of colour equal in size to the menu bar but displaced insde the client region.
hdc = GetWindowDC(hWnd);
MENUBARINFO menuInfo = { sizeof(MENUBARINFO) };
if (GetMenuBarInfo(hWnd, OBJID_MENU, 0, &menuInfo))
{
HBRUSH hBrush = CreateSolidBrush(AppColor);
RECT rcFill{ menuInfo.rcBar };
FillRect(hdc, &rcFill, hBrush);
DeleteObject(hBrush);
}
ReleaseDC(hWnd,hdc);
In the code below, I expect the entire window non-client area to be filled with a specified colour. Instead what I see is a band of area with size identical to the window frame but displaced from the window frame filled with the specified colour.
HDC hdc = GetWindowDC(hWnd);
HBRUSH hBrush = CreateSolidBrush(AppColor);
HRGN hFillRgn = (HRGN)wParam;
if (!FillRgn(hdc, hFillRgn, hBrush))
{
long lErrorCode = GetLastError();
GetErrorMessageBox(lErrorCode);
}
DeleteObject(hBrush);
ReleaseDC(hWnd,hdc);
What I have tried:
I have read documentation on the two functions. It did not help.