[Interest] win: can't trap WM_ENTER/EXITMENULOOP?

Volker Hilsheimer volker.hilsheimer at qt.io
Mon Oct 25 19:34:59 CEST 2021


QMenuBar is not a Win32 native menu bar, and neither is QMenu backed by a native win32 menu. Windows knows nothing about their role in the UI (unless it asks for it via accessibility infrastructure, but that’s unrelated to those messages).

Volker

________________________________
From: Interest <interest-bounces at qt-project.org> on behalf of David M. Cotter <dave at kjams.com>
Sent: Monday, October 25, 2021 6:39:40 PM
To: Qt Interest <Interest at qt-project.org>
Subject: [Interest] win: can't trap WM_ENTER/EXITMENULOOP?


in the documentation here<https://docs.microsoft.com/en-us/windows/win32/menurc/menus>, it indicates i can get a message when the menu bar starts to be browsed, and another when the browsing is completed.

this is exactly what i need (the purpose is unrelated to this post).

So in my QMainWindow derived class, i override the nativeEvent() method, like so:

bool    QBrowserWindow::nativeEvent(
        const QByteArray&       eventType,
        void                    *messageP,
        qintptr                 *resultP)
{
        bool            handledB(false);

        if (eventType == kWindowsEventType_GENERIC) {
                MSG&            msg(*(MSG *)messageP);

                switch (msg.message) {

                        default: {
                                //      nothing else
                        } break;

                        case WM_ENTERMENULOOP: {
                                Log("start menu browsing");
                                SuspendTableUpdates(true);
                        } break;

                        case WM_EXITMENULOOP: {
                                Log("end menu browsing");
                                SuspendTableUpdates(false);
                        } break;
                }
        }

        return handledB;
}


However, those messages are never sent :(

Any idea why not?

-dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20211025/b5b98f3a/attachment.html>


More information about the Interest mailing list