Can I add a menu bar to a WxDialog?

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
tbreina
Moderator
Moderator
Posts: 1289
Joined: Thu Nov 25, 2004 7:38 pm
Location: Coronado, CA

Can I add a menu bar to a WxDialog?

Post by tbreina »

I've been using wx-devcpp for development and have the hang of creating projects with wxDialog. It doesn't seem like I can add menu bars to these dialog boxes. Is that true?

Assuming no, then I've been trying to create a wxFrame project (which looks like it can accept menu bars in wx-devcpp). However, I can't figure out how to add things like text boxes, buttons, etc. to the frame. Is it possible to add a wxDialog to a wxFrame?

Everything else seems pretty straightforward in wx-devcpp, but this one's kicking my butt.

Thanks in advanced.

-Tony
NinjaNL
Moderator
Moderator
Posts: 899
Joined: Sun Oct 03, 2004 10:33 am
Location: Oosterwolde, Netherlands

Re: Can I add a menu bar to a WxDialog?

Post by NinjaNL »

tbreina wrote:I've been using wx-devcpp for development and have the hang of creating projects with wxDialog. It doesn't seem like I can add menu bars to these dialog boxes. Is that true?
No, wxDialogs can have system menu's but not user created menus. If you need a menu, use a wxFrame.
Assuming no, then I've been trying to create a wxFrame project (which looks like it can accept menu bars in wx-devcpp). However, I can't figure out how to add things like text boxes, buttons, etc. to the frame. Is it possible to add a wxDialog to a wxFrame?
wxFrame can accept menubars, toolbars etc. but you can't add a dialog to a frame.

Check out my explanation here on using wxDevCpp's form editor.
Everything else seems pretty straightforward in wx-devcpp, but this one's kicking my butt.

Unfortunately Guru has mentioned elsewhere that he won't be working on wxDevCpp for a couple of months, which means that we'll all be having that feeling for a while. Someone else offered to assist in the coding of wxDevCpp so it may be that he will extend it further, but I don't know for sure.
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/
tbreina
Moderator
Moderator
Posts: 1289
Joined: Thu Nov 25, 2004 7:38 pm
Location: Coronado, CA

Re: Can I add a menu bar to a WxDialog?

Post by tbreina »

>> wxFrame can accept menubars, toolbars etc. but you can't add a dialog to a frame.

Yikes, so is this a catch-22? Why wouldn't there be a way to have dialogs and user-defined menus working?

I've found that text boxes, buttons, and menu bars work on wxFrame, but that the wxFileDialog (along with other dialog buttons) won't display. wx-devcpp seems to add them to the frame, but they are hidden during run-time. Is this an error (wx-devcpp is allowing me to do something in the developer that isn't possible in run-time)?

Basically, I just want a way to have a user-defined menu, an editable text box, a button, and a way to select a file (wxFileDialog or whatever is possible).
User avatar
ABX
Can't get richer than this
Can't get richer than this
Posts: 810
Joined: Mon Sep 06, 2004 1:43 pm
Location: Poznan, Poland
Contact:

Re: Can I add a menu bar to a WxDialog?

Post by ABX »

tbreina wrote:>> wxFrame can accept menubars, toolbars etc. but you can't add a dialog to a frame.

Yikes, so is this a catch-22? Why wouldn't there be a way to have dialogs and user-defined menus working?
Because it is not possible in all or majority of supported platforms. wxWidgets is a wrapper around native objects to provide native look&feel. If native dialogs if operating system does not provide menu in dialog, how could wxWidgets do it?

However there is one small exception to this rule. Smartphone driven by WinCE does not at all support buttons control while they natively have menubar all the time on screen and therefore buttons are translated there to native menu in dialogs (at least these common).
tbreina wrote:I've found that text boxes, buttons, and menu bars work on wxFrame, but that the wxFileDialog (along with other dialog buttons) won't display.
Look into manual. wxFileDialog is derived from wxDialog, not from wxFrame. From the fact that something happens for wxFrame you cannot conclude it should work the same on wxDialog (especially common dialog which use native not adjustable object wherever possible).
tbreina wrote:wx-devcpp seems to add them to the frame, but they are hidden during run-time. Is this an error (wx-devcpp is allowing me to do something in the developer that isn't possible in run-time)?
I cannot help here. I do not know wx-devcpp.
tbreina wrote:Basically, I just want a way to have a user-defined menu, an editable text box, a button, and a way to select a file (wxFileDialog or whatever is possible).
Have you compiled samples provided. It seems like you are looking for the functionality which already is presented there.

ABX
CVS Head, 2.8.X
wxMSW, wxWinCE, wxPalmOS, wxOS2, wxMGL, bakefile
gcc 3.2.3, bcc 5.51, dmc 8.48, ow 1.6, vc 7.1, evc 3/4, pods 1.2
tbreina
Moderator
Moderator
Posts: 1289
Joined: Thu Nov 25, 2004 7:38 pm
Location: Coronado, CA

Re: Can I add a menu bar to a WxDialog?

Post by tbreina »

Ok. I seem to have found how to do this after a little more fumbling around.

Although I can't add the OpenFileDialog box to a wxFrame, I can add a button to the frame which opens the FileDialog dialog box when it is clicked. I suppose I was thinking that the tool in wx-devcpp could do this if you try to add an OpenFileDialog to a frame.

Anyway, wx-devcpp is still a great development tool. I hope Guru's health and job situation continue to improve.


-Tony
NinjaNL
Moderator
Moderator
Posts: 899
Joined: Sun Oct 03, 2004 10:33 am
Location: Oosterwolde, Netherlands

Re: Can I add a menu bar to a WxDialog?

Post by NinjaNL »

tbreina wrote:Although I can't add the OpenFileDialog box to a wxFrame
You CAN add an OpenFileDialog box to a frame, or more accurately to a FORM. Select the newProgramFrame.wxform file (or whatever you have called yours) then in the drop down list on the right hand side, select dialogs. In the list of dialogs clock ONCE on OpenFileDialog then ONCE on the form. You should see an icon which represents the dialog. If you look at the generated code you will see that there is a reference to the OpenFileDialog. You do have to show the dialog yourself, either from a menu selection or from a button press, but the basic code is already there.
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/
gururamnath
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Re: Can I add a menu bar to a WxDialog?

Post by gururamnath »

tbreina wrote:
I've found that text boxes, buttons, and menu bars work on wxFrame, but that the wxFileDialog (along with other dialog buttons) won't display. wx-devcpp seems to add them to the frame, but they are hidden during run-time. Is this an error (wx-devcpp is allowing me to do something in the developer that isn't possible in run-time)?
This problem is fixed in the beta 6.5. Please upgrade to this version.

Thanks,
Guru Kathiresan
tbreina
Moderator
Moderator
Posts: 1289
Joined: Thu Nov 25, 2004 7:38 pm
Location: Coronado, CA

Re: Can I add a menu bar to a WxDialog?

Post by tbreina »

Guru,

I think this was with the 6.5 beta. I downloaded it from the link you posted on this forum. However, the executable still says 6.4beta so I'm not sure if the link you had was correct. Could you provide a new link on the website?

Thanks.
-Tony
gururamnath
Super wx Problem Solver
Super wx Problem Solver
Posts: 466
Joined: Sat Sep 18, 2004 2:49 am
Location: California, USA

Re: Can I add a menu bar to a WxDialog?

Post by gururamnath »

tbreina wrote:Guru,

I think this was with the 6.5 beta. I downloaded it from the link you posted on this forum. However, the executable still says 6.4beta so I'm not sure if the link you had was correct. Could you provide a new link on the website?
Tony,
I havent renamed the version to 6.5 but the changes I mentioned previously are added to it. If you have any invisible components, try to remove them from the form and try adding new one. Let me know if this is of any help.

-Guru Kathiresan
Post Reply