Hello @infinityeternity ,
You need to handle WM_NCLBUTTONDOWN separately.
wParam
The hit-test value returned by the DefWindowProc function as a result of processing the WM_NCHITTEST message. For a list of hit-test values, see WM_NCHITTEST.
Therefore, the value you return from WM_NCHITTEST is sent in the wParam of other messages, notably WM_NCLBUTTONDOWN and WM_NCLBUTTONUP.
Modify it like this:
LRESULT CALLBACK msg_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE:
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); // inform frame change
break;
case WM_NCCALCSIZE:
if (wParam) return 0; // removing the standard frame
break;
case WM_NCHITTEST:
return HTCLOSE; // HTCAPTION perfectly works
case WM_NCLBUTTONDOWN:
if (wParam == HTCLOSE)
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
...
Thank you!
----------
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.