Page 1 of 1

Need Directions Placing Controls on a Form

Posted: Tue Apr 26, 2016 11:42 pm
by ColleenKobe
Hi! I'm trying to re-create the following form. It was originally written in Visual Basic 6.
Comm Interface.jpg
I have figured out how to create the "Com Port" radio button column. I have put a "Refresh" button below it, but the button is not inside the radio button box. I hope my project engineer can live with that.

Now I'm trying to add the "Enable Com Interface" checkbox, the Communication Port Status text, the Temporary File Path text dialog, and the Browse button on the page. I am at a loss. What happens is that I have the first sizer set up on the page to be vertical, so anything I add later on is appended to the bottom of the screen. If I change it to Horizontal, then EVERYTHING appends to the right.

What I really want is for the new group of controls to be beside the radio buttons field.

I think the wxFlexGrid sizer might work. I just need to figure out how to put more than one control in the right frame of the sizer. See the picture below.
Comm Interface Failure Screen Shot.jpg
Can you please tell me how to put the checkbox, text box, text label and box, and refresh button, all in the sizer area to the right of the radio buttons, so that they match the original drawing more?

Thanks!!!

Colleen

------------------
Software Versions:
------------------
CodeLite = 9.1.6
g++ = 4.9.3
tdm-g++ = 5.1.0.3
Windows 7 = 6.1
wxCrafter = 2.5
wxWidgets = 3.1.0

Re: Need Directions Placing Controls on a Form

Posted: Wed Apr 27, 2016 12:15 pm
by eranif
It all about playing with the sizers
See attached wxcp file that shows how to get the desired form:
com-form.png
You should really do some reading on how wxSizers are working (there are various types of sizers)
Eran

Re: Need Directions Placing Controls on a Form

Posted: Wed Apr 27, 2016 4:57 pm
by ColleenKobe
Hi, Eran,

WOW! This is fabulous! Thank you so much for giving me this example! I work far better from a good example than from lists of tools. An example shows me how to put the pieces together to get a specific result. Like a jigsaw puzzle. I can use this code in my current project, and it will be a wonderful reference in the future for me. THANK YOU!

In answer to your suggestion that I read up on sizers--you are right. I have read up on sizers, but obviously not enough.

My big problem is that I can't see the sizers. I know I can set the various flags in the Styles and Sizer Flags tabs for controls, and I have seen how the value those flags affect the controls. Even so, I can't tell how wide the sizers are (as opposed to the controls), or how tall, or what percentage of the screen they take up.

Currently, I'm visualizing sizers in my head like Microsoft Word tables, and each cell is a sizer, and I'm trying to insert and move things around in the cells. But if the cell sizes vary, and I can't see where they are on this blank page, then I likely don't put controls in the right places.

Is there a way to turn sizer viewing on? So I can see them all the time?

Colleen

Re: Need Directions Placing Controls on a Form

Posted: Wed Apr 27, 2016 5:53 pm
by marcelinux
Can I sugest you a review of http://zetcode.com/gui/wxwidgets/layoutmanagement/
It helped me to understand sizers.

Re: Need Directions Placing Controls on a Form

Posted: Wed Apr 27, 2016 9:07 pm
by DavidGH
Hi,
Is there a way to turn sizer viewing on?
It's permanently on. Just select a sizer in the tree view; as in the screenshot it should be outlined in a tasteful orange.
It's not 100% reliable, and there's a tendency for one edge to be missed, as in the screenshot; but it usually works well enough.
So I can see them all the time?
No, that would be too 'busy', and conflict with the outlining of the controls.

Another good place to learn about wxBoxSizers is http://neume.sourceforge.net/sizerdemo/.

Regards,

David