开发者

wxDialog with the wxMenuBar

开发者 https://www.devze.com 2023-01-22 14:31 出处:网络
I have tons of existing code using wxWidgets. The main window is wxDialog.开发者_运维百科 Now I have to add a wxMenuBar to that dialog. But, in order to do it, the window should be derived from wxFram

I have tons of existing code using wxWidgets. The main window is wxDialog.开发者_运维百科 Now I have to add a wxMenuBar to that dialog. But, in order to do it, the window should be derived from wxFrame.

Is it possible to add a wxMenuBar to the wxDialog? If not, is it possible to convert existing code in a way that main window is derived from wxFrame instead from wxDialog?


It's not possible to add a native menu bar to a wxDialog, however, it is possible to use a non-native menu bar control like wxFlatMenuBar (not included with wxWidgets), and add it to the top of the dialog as if it was just another control. Also note though that besides being a non-native menu bar, you also won't be able to use some wxWidgets API to manage it like wxUpdateUIEvents.

There's at least a couple things you will need to take into consideration when changing a wxDialog to a wxFrame.

First, if your dialog is a modal dialog, you will need to manually set the new frame as modal (using wxWindow::MakeModal()) rather than calling ShowModal().

Second, if you had any event handlers setup for the affirmative (OK/Apply button for example) or escape (Cancel or window close) events, you will likely need to rewrite them to handle changes in window behavior.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号