diff --git a/examples/Win32Demo/widget.cpp b/examples/Win32Demo/widget.cpp index 1d3d491..d3b5859 100644 --- a/examples/Win32Demo/widget.cpp +++ b/examples/Win32Demo/widget.cpp @@ -187,25 +187,27 @@ bool Widget::nativeEvent(const QByteArray &eventType, void *message, long *resul Q_ASSERT(eventType == "windows_generic_MSG"); Q_ASSERT(message); Q_ASSERT(result); - const auto msg = static_cast(message); - const auto getCursorPosition = [](const LPARAM lParam) -> QPoint { - return {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; - }; - switch (msg->message) { - case WM_NCRBUTTONUP: { - const QPoint pos = getCursorPosition(msg->lParam); - qDebug() << "WM_NCRBUTTONUP -->" << pos; - if (WinNativeEventFilter::displaySystemMenu(msg->hwnd, false, pos.x(), pos.y())) { - *result = 0; - return true; + if (ui->customizeTitleBarCB->isChecked()) { + const auto msg = static_cast(message); + const auto getCursorPosition = [](const LPARAM lParam) -> QPoint { + return {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; + }; + switch (msg->message) { + case WM_NCRBUTTONUP: { + const QPoint pos = getCursorPosition(msg->lParam); + qDebug() << "WM_NCRBUTTONUP -->" << pos; + if (WinNativeEventFilter::displaySystemMenu(msg->hwnd, false, pos.x(), pos.y())) { + *result = 0; + return true; + } + break; + } + case WM_RBUTTONUP: + qDebug() << "WM_RBUTTONUP -->" << getCursorPosition(msg->lParam); + break; + default: + break; } - break; - } - case WM_RBUTTONUP: - qDebug() << "WM_RBUTTONUP -->" << getCursorPosition(msg->lParam); - break; - default: - break; } return QWidget::nativeEvent(eventType, message, result); }