mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
fix: 修复导航栏收起时左上边框命中测试错误
This commit is contained in:
parent
d3b32614b6
commit
df1b99925b
1 changed files with 6 additions and 6 deletions
|
|
@ -424,11 +424,11 @@ LRESULT MainWindow::_TitleBarMessageHandler(UINT msg, WPARAM wParam, LPARAM lPar
|
|||
case WM_NCHITTEST:
|
||||
{
|
||||
POINT cursorPos{ GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam) };
|
||||
ScreenToClient(_hwndTitleBar.get(), &cursorPos);
|
||||
ScreenToClient(Handle(), &cursorPos);
|
||||
|
||||
RECT titleBarClientRect;
|
||||
GetClientRect(_hwndTitleBar.get(), &titleBarClientRect);
|
||||
if (!PtInRect(&titleBarClientRect, cursorPos)) {
|
||||
RECT clientRect;
|
||||
GetClientRect(Handle(), &clientRect);
|
||||
if (!PtInRect(&clientRect, cursorPos)) {
|
||||
// 先检查鼠标是否在窗口内。在标题栏按钮上按下鼠标时我们会捕获光标,从而收到 WM_MOUSEMOVE 和 WM_LBUTTONUP 消息。
|
||||
// 它们使用 WM_NCHITTEST 测试鼠标位于哪个区域
|
||||
return HTNOWHERE;
|
||||
|
|
@ -440,7 +440,7 @@ LRESULT MainWindow::_TitleBarMessageHandler(UINT msg, WPARAM wParam, LPARAM lPar
|
|||
// 鼠标位于上边框
|
||||
if (cursorPos.x < resizeHandleHeight) {
|
||||
return HTTOPLEFT;
|
||||
} else if (cursorPos.x + resizeHandleHeight >= titleBarClientRect.right) {
|
||||
} else if (cursorPos.x + resizeHandleHeight >= clientRect.right) {
|
||||
return HTTOPRIGHT;
|
||||
} else {
|
||||
return HTTOP;
|
||||
|
|
@ -461,7 +461,7 @@ LRESULT MainWindow::_TitleBarMessageHandler(UINT msg, WPARAM wParam, LPARAM lPar
|
|||
}
|
||||
|
||||
// 从右向左检查鼠标是否位于某个标题栏按钮上
|
||||
const LONG cursorToRight = titleBarClientRect.right - cursorPos.x;
|
||||
const LONG cursorToRight = clientRect.right - cursorPos.x;
|
||||
if (cursorToRight < buttonWidthInPixels) {
|
||||
return HTCLOSE;
|
||||
} else if (cursorToRight < buttonWidthInPixels * 2) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue