0

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++

cobie
  • 7,023
  • 11
  • 38
  • 60
  • If you didn't have the `.net` tag I would have suggested this: http://stackoverflow.com/a/5739620/5987 Perhaps a similar approach is possible. – Mark Ransom May 08 '12 at 17:18

2 Answers2

5

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)));
Rasmus Søborg
  • 3,597
  • 4
  • 29
  • 46
  • If you want the control to "float", then attach to the bottom and the right. Play around with it and you will see the different behaviors. – Oblivion2000 May 08 '12 at 17:20
0

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.

Hearty
  • 543
  • 1
  • 5
  • 16