[英]WM_NCHITTEST not changing mouse cursor
I have a Layered Window (WS_EX_LAYERED) that implements a custom NCHITTEST and NCCALCSIZE to make the client rect of my window the same as the window rect. 我有一个分层窗口(WS_EX_LAYERED),它实现了一个自定义的NCHITTEST和NCCALCSIZE,使我的窗口的客户端矩形与窗口矩形相同。 My window sizes and paints correctly;
我的窗户尺寸和油漆正确; I can return HTBOTTOM from WM_NCHITTEST when the cursor is near the bottom edge of my window to cause a vertical-resize-window-from-the-bottom type action.
当光标靠近窗口的下边缘时,我可以从WM_NCHITTEST返回HTBOTTOM,从而导致垂直调整大小窗口从底部类型操作。 However, I am not getting the vertical resize cursor.
但是,我没有得到垂直调整大小的光标。 Is there way a do fix this without having to implement WM_SETCURSOR and test the pointer's position vs the edges of the windows?
有没有办法解决这个问题,而不必实现WM_SETCURSOR并测试指针的位置与窗口的边缘?
Here's a snippet of my code: 这是我的代码片段:
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;
}
You need to handle the WM_SETCURSOR message - the low-order word of lParam specifies the hit-test code. 您需要处理WM_SETCURSOR消息 - lParam的低位字指定命中测试代码。
For instance, 例如,
case WM_SETCURSOR:
switch (LOWORD(lParam))
{
case HTBOTTOM:
SetCursor(LoadCursor(0, IDC_SIZENS));
return 0;
}
}
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.