我有一个分层窗口 (WS_EX_LAYERED),它实现了自定义 NCHITTEST 和 NCCALCSIZE,以使我的窗口的客户端矩形与窗口矩形相同。我的窗户尺寸和油漆正确;当光标靠近窗口的底部边缘时,我可以从 WM_NCHITTEST 返回 HTBOTTOM 以导致从底部开始垂直调整窗口大小类型的操作。但是,我没有得到垂直调整大小光标。有没有办法解决这个问题而不必实现 WM_SETCURSOR 并测试指针的位置与窗口的边缘?
这是我的代码片段:
case WM_NCCALCSIZE:
// Bypass DefWindowProc, so the Window Rect == Client Rect
return 0;
case WM_NCHITTEST: {
RECT w;
::GetWindowRect(hwnd, &w);
// Compare the mouse X/Y vs the rect of the window to detect
// resizing from the bottom edges
int r = HTCLIENT;
int x = GET_X_LPARAM(lParam);
int y = GET_Y_LPARAM(lParam);
if (w.bottom - y < 10) {
// If I was not using NCHITTEST, I should get a verticle resize pointer here
if (x - w.left < 10)
r = HTBOTTOMLEFT;
else if (w.right - x < 10)
r = HTBOTTOMRIGHT;
else
r = HTBOTTOM;
}
return r;
}