I have an overridden non-client area of my window in the window callback function as follows:
case WM_NCPAINT: { HDC hdc; RECT rect; HPEN pen; hdc=GetDCEx(hWnd,(HRGN)wParam,DCX_WINDOW|DCX_CACHE|DCX_INTERSECTRGN|DCX_LOCKWINDOWUPDATE); GetWindowRect(hWnd,&rect); pen=CreatePen(PS_SOLID, 10, RGB(255, 0, 0));//red pen 10 pixels in size SelectObject(hdc,pen); Rectangle(hdc,0,0,(rect.right-rect.left),(rect.bottom-rect.top)); DeleteObject(pen); ReleaseDC(hWnd,hdc); RedrawWindow(hWnd,&rect,(HRGN)wParam,RDW_UPDATENOW) }break;
What the trick does is, and in the example above, draws a red rectangle around my window. However, if the window loses focus, then by default the non-client area is colored, and my custom drawing of the non-client area disappears.
I tried to catch the WM_KILLFOCUS message in my window callback function and did the same with it as with WM_NCPAINT, but did nothing (although I saw that I get this message when I click on another window and my loss window).
What am I missing here ...?
source share