tags:

views:

31

answers:

1

I am currently designing the migration of my existing .NET / C# / WinForms project to a platform neutral solution and the most attractive alternative I have seen seems to be wxWidgets especially taking in consideration my familiarity with C++ and with MFC that appears to have a lot in common with it.

After going though the documentation and the sample code I need to clarify the following issue:

Is it a valid assumption that the way to develop a User Control (by C# terminology) in a wx environment is to derive a class from wxPanel , customize it and place it in a wxFrame? If this is the case what is the wxFrame method to be used to add the wxPanel object to it ?

The only relative method I was able to find was wxWindow::AddChild but the documentation states that is mostly internal to wxWidgets and shouldn't be called by the user code.

To avoid confusion please note that my question is about a User Control and not a Custom Control (which is clearly addressed in the documentation)

+1  A: 

I think you have to set the parent window in the constructor of your wxPanel-derived class and pass it to the inherited constructor (cf. wxPanel constructor)

A better solution, though, is to use sizers (see wx Sizers) for layouting.

And yes, imo you're right about wxPanelbeing (roughly) the equivalent of a C# UserControl.

MartinStettner
JohnP
You have always to give the parent window in the constructor. The sizer mechanism works in parallel: you add all child controls to the sizer (using `sizer->Add`) and set the parent's sizer property afterwards (using `parent->SetSizer`). Take a look at the (second) link, there's a short example.
MartinStettner
Got it... I will go ahead and download the framework and give it a try!
JohnP