cobie
cobie

Reputation: 7271

Resizing controls when form is resized

newbie with windows gui programming here. Has Anyone got an idea how to resize controls in a windows form when the form is resized. In wxpython, it was done with the sizers but I cannot seem to find anything similar when developing guis with windows visual c++

Upvotes: 0

Views: 2435

Answers (2)

Rasmus Søborg
Rasmus Søborg

Reputation: 3695

A control has a member called "Anchor". You can see it from the editor. If you want the object to keep its positioning in all four corners of it's rectangle you can simply enable all of the sub properties under Anchor.

You can read more about the member here: Microsoft.com/Anchor. If you want to dynammicly enable the properties of an control you can simply use this example:

Control.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top |   System.Windows.Forms.AnchorStyles.Bottom) 
        | System.Windows.Forms.AnchorStyles.Left) 
        | System.Windows.Forms.AnchorStyles.Right)));

Upvotes: 5

Hearty
Hearty

Reputation: 543

I managed to change it from Form1.h using

Form1->Width = 300;
Form1->Height = 300;

inside the event (say, when you click button1). More can be read here.

Upvotes: 0

Related Questions