Question about sizers and modal dialogs

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Morat20
Knows some wx things
Knows some wx things
Posts: 39
Joined: Tue Jan 07, 2014 8:43 pm

Question about sizers and modal dialogs

Post by Morat20 » Thu May 07, 2020 5:35 pm

So I want to build a modal dialog with sizers.

That's straightforward enough. I build my dialog, lay out my sizers, and then....I get confused, mostly because I've never actually sorted out all the various iterations of Fit(), Layout(), SetSizer(), etc.

My modal dialog is referenced off my main frame (just call it frame).

So I have

MyCoolDialog = new MyModalDialog(frame, ......);

wxBoxSizer *example = new wxBoxSizer(wxHORIZONTAL).
example->Add(ListBoxControl1,0,0,0);
example->Add(ListBoxControl2,0,0,0);
....

but then I get that done, how do I actually tell the dialog "Figure out your layout, then size yourself to fit the controls?" For some reason SetSizerAndFit() seems to adjust my main frame, which I explicitly don't want. But if I don't use that, the controls don't lay out at all

How exactly do I tell JUST that dialog "Figure out your layout, adjust your own size to fit your internal controls""?

User avatar
doublemax
Moderator
Moderator
Posts: 14786
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Question about sizers and modal dialogs

Post by doublemax » Thu May 07, 2020 5:39 pm

SetSizerAndFit() should work, but you need to call it on the dialog, not the frame. If that's not the error, post more code.
Use the source, Luke!

Morat20
Knows some wx things
Knows some wx things
Posts: 39
Joined: Tue Jan 07, 2014 8:43 pm

Re: Question about sizers and modal dialogs

Post by Morat20 » Thu May 07, 2020 5:39 pm

Thanks. That's exactly the mistake I was making.

Post Reply