tags:

views:

21

answers:

1

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?

A: 

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.

Bryan Petty
Thank you for answering. After some digging, I've come to the same conclusion - no menu on the wxDialog. Since this application runs only on Windows OS, I decided to add a menu by using pure Win32 API. It works as expected. Regarding wxDialog->wxFrame change, I've had too many problems, so I decided to drop that approach. But, this considerations you mentioned are good to know!
natko