I just tryed the standard way for adding CToolbar to a dialog on the new CMFCToolBar. But it doesn't work. Befor I dip into the new implementation, I want to know if it actually possible?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
I'm not sure what you mean by "the standard way", but you can certainly do it programatically:
The
OnInitDialog
above does work well except in cases where the command is a dialog-only command.If there is no application or main-frame handler the button disables itself and the handler is not called. Note that the above code routes correctly because
ID_APP_ABOUT
andID_APP_EXIT
already haveCWinAppEx
handlers.A workaround that does not involve overriding
OnCmdMsg
is to add a handler at the application or main-frame level. The toolbar then stays active and will correctly find its way to the proper dialog handler. Adding a simple void handler toCMainFrame
does the trick (sample code below). The void handler is not called.If you only have to deal with dialog-only commands the trick is to set SetRouteCommandsViaFrame to FALSE. Then the owner (usually the dialog) will be used for commands instead of the main frame.