I had the same problem. The problem is that left-clicking on the window title causes a drag and drop, and thus mouse capture, which prevents the arrival of WM_NCLBUTTONUP.
The solution is to override WM_NCHITTEST:
LRESULT CALLBACK WndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
switch (nMsg)
{
...
case WM_NCHITTEST:
Point p(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam);
ScreenToClient(p);
if (myButtonRect.Contains(p))
{
return HTBORDER;
}
break;
}
return DefWindowProc(hWnd, nMsg, wParam, lParam);
}
, , , Windows, , , , (HTBORDER).
: SetCapture() ReleaseCapture(), , WM_NCLBUTTONDOWN , . , , /, . SetTimer()/KillTimer() (, 100 ), WM_NCLBUTTONUP.