【发布时间】:2026-01-22 15:50:01
【问题描述】:
我想要一个没有边框和标题的窗口,所以我做了 SetWindowLongPtrW(window_handle, GWL_STYLE, 0);
在那之后我不能移动我的窗口所以在我的 WndProc 中我这样做了
if( message == WM_NCHITTEST ) {
RECT rc;
GetClientRect( hwnd, &rc );
MapWindowPoints( hwnd, GetParent( hwnd ), (LPPOINT)&rc, 2 );
int mouseX = LOWORD( lParam ) - rc.left;
int mouseY = HIWORD( lParam ) - rc.top;
POINT p;
p.x = mouseX;
p.y = mouseY;
return PtInRect( &rc, p ) ? HTCAPTION : DefWindowProc( hwnd, message, wParam, lParam );
}
它工作,我第一次移动窗口。在我停止用鼠标点击后,它不会再次移动:/
【问题讨论】:
-
将您的代码与already existing implementation进行比较。
标签: windows winapi window wndproc