当我的应用程序处理这些 Windows 事件时,我的应用程序有 aQLineEdit
和 aQPushButton
不能正确响应键盘和鼠标的输入(QLineEdit
不接收键盘输入,并且两者QLineEdit
都没有接收鼠标输入):QPushButton
bool MainWindow::winEvent(MSG *msg, long *result)
{
HWND hWnd = msg->hwnd;
UINT message = msg->message;
WPARAM wParam = msg->wParam;
LPARAM lParam = msg->lParam;
bool retval = true;
LRESULT lRet = 0;
switch(message)
{
case WM_PAINT:
{
HDC hDC = GetWindowDC(hWnd);
PaintCustomCaption(hWnd, hDC); //Method responsible to draw the image at the non client area
DeleteDC(hDC);
break;
}
case WM_NCHITTEST:
{
lRet = HitTestNCA(hWnd, lParam); //Method responsible to deal with the window resizing and moving
DwmDefWindowProc(hWnd, message, wParam, lParam, &lRet);
break;
}
case WM_NCCALCSIZE:
{
break;
}
default:
{
retval = false;
DwmDefWindowProc(hWnd, message, wParam, lParam, &lRet);
break;
}
}
*result = lRet;
if(retval) return true;
return QWidget::winEvent(msg, result);
}
如果我删除此类代码,我的 Qt 小部件可以正常工作,但我需要这些代码,因为我的应用程序正在窗口的非客户区绘制图像。
是否可以处理上面列出的 Windows 事件,让我的 Qt 小部件响应键盘和鼠标?