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

Scott Bloom scott at towel42.com
Mon Oct 25 20:43:34 CEST 2021


You are mixing and confusing windows native Win32 messages with Qt signals.

You are making the incorrect assumption that the Qt core internals are based on Windows native widgets.  That is your mistake.

Instead look into QMenu::aboutToShow and QWidget::closeEvent

Your solution (if it worked) would only work on Windows, not linux, mac or any other platform.  Using Qt's native system will work on all platforms

Scott

From: Interest <interest-bounces at qt-project.org> On Behalf Of David M. Cotter
Sent: Monday, October 25, 2021 9:40 AM
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/cb98cc01/attachment.html>


More information about the Interest mailing list