- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 win32 创建一个带有自定义标题栏和边框的窗口。我的问题是,当我使用 WM_NCHITTEST
WM_LBUTTONDOWN
时,点击事件不会被触发。当我没有使用 WM_NCHITTEST
时,我收到了点击事件。我没有收到任何错误。
我已经尝试删除 WM_NCHITTEST
中的代码,所以我只返回 0
。我试过删除 WM_NCHITTEST
然后 WM_LBUTTONDOWN
工作,但我需要两者都工作。
//Declaring before switch
int x, y;
RECT rect;
int iTitlebarY = 20;
case WM_NCHITTEST: {
GetWindowRect(hwnd, &rect);
x = GET_X_LPARAM(lParam);
y = GET_Y_LPARAM(lParam);
if (y <= rect.top + iTitlebarY) {
return HTCAPTION;
}
//Some more code for resizing...
return 0;
}
case WM_LBUTTONDOWN:
//Never gets triggered
//Do something...
我预计我会收到鼠标点击,因为当我不使用 WM_NCHITTEST
时我会收到。
最佳答案
来自 WM_LBUTTONDOWN
留言
Posted when the user presses the left mouse button while the cursor is in the client area of a window
将此与 WM_NCLBUTTONDOWN
进行比较留言
Posted when the user presses the left mouse button while the cursor is within the nonclient area of a window
但是窗口的哪一部分是客户区?确定这个存在WM_NCHITTEST
留言:
Sent to a window in order to determine what part of the window corresponds to a particular screen coordinate
仅当您返回 HTCLIENT
以响应 WM_NCHITTEST
- 您在客户区。只有在这种情况下,您才会得到 WM_LBUTTONDOWN
但您永远不会返回 HTCLIENT
来响应 WM_NCHITTEST
- 您总是返回 0,这意味着 HTNOWHERE
所以不是返回 HTNOWHERE
你需要调用 DefWindowProc
并返回它的值:
//return HTNOWHERE;
return DefWindowProc(hWnd, Msg, wParam, lParam);
或者你自己以某种方式检测你的客户区是什么,并在光标位于窗口的客户区时返回 HTCLIENT
关于C++ WM_LBUTTONDOWN 在使用 WM_NCHITTEST 时不触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57942789/
出于某种原因,我似乎无法在标签(“STATIC”窗口)上捕捉到 WM_LBUTTONDOWN 事件。使用 Winspector 进行监视时,消息似乎总是到达父窗口。但是,根据 docs ,消息应该发布
我有一个 WindowProcess,它会在按下鼠标左键时创建一个线程: case WM_LBUTTONDOWN: { InvalidateRect(hwnd, NULL, TRUE);
MSG的结构如下: typedef struct tagMSG { HWND hwnd; UINT message; WPARAM wParam; LPARAM lParam;
我正在使用 win32 创建一个带有自定义标题栏和边框的窗口。我的问题是,当我使用 WM_NCHITTEST WM_LBUTTONDOWN 时,点击事件不会被触发。当我没有使用 WM_NCHITTES
我创建了顶层窗口,但由于未知原因,我的 WNDPROC 没有收到 WM_LBUTTONDOWN/WM_LBUTTONUP 和 WM_MOUSEMOVE 消息。 有什么建议吗? 相关代码: WNDCLA
我有一些关于 WM_COMMAND 的问题。 如果我在 WM_COMMAND 的 case 分支中更改变量 x 是否有可能在 WM_LBUTTONDOWN 的 case 分支中获得这个新值?我总是在
我正在创建一个带有如下下拉列表的窗口: 如果我单击前四个选项中的任何一个,包括它们的子选项,那么我想处理该选项。问题是我需要在这些选项中使用 WM_LBUTTONDOWN、WM_LBUTTONUP 和
我正在运行 theForger's Win32 API Programming Tutorial .在 page 4他建议在列出所有 WM_* 消息的 API 头文件中找到 #define 语句列表会
我是一名优秀的程序员,十分优秀!