[英]Is it possible to increase a window's border area for resizing the window with the mouse?
[英]Resizing window cannot be stopped when release mouse button
LRESULT window_procedure(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
switch (message)
{
case WM_MOVE:
{
return 0; // (1)
}
case WM_SIZE:
{
return 0;
}
case WM_PAINT:
{
ValidateRect(window, NULL); // (2)
return 0;
}
}
return DefWindowProcA(window, message, wparam, lparam);
}
while (TRUE)
{
MSG message;
BOOL result = PeekMessageA(&message, NULL, 0, 0, PM_REMOVE);
TranslateMessage(&message);
DispatchMessageA(&message);
}
我有這段代碼,我發現當我調整 window 的大小時,當我釋放鼠標按鈕時,調整大小的手柄不會自動釋放。
我嘗試過的一些可以解決這個問題的方法是:
DefWindowProc
ValidateRect
請告訴我這些有什么意義!
問題在這里:
while (TRUE)
{
MSG message;
BOOL result = PeekMessageA(&message, NULL, 0, 0, PM_REMOVE);
TranslateMessage(&message);
DispatchMessageA(&message);
}
即使result
為FALSE
,代碼也會繼續發送消息。 要么將TranslateMessage
和DispatchMessage
調用包裝在if (result)
條件中,要么正確初始化變量( MSG message{};
),或者 go 使用更傳統的消息循環調用GetMessage
代替PeekMessage
(請參閱使用消息和消息隊列)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.