I am writing trying to learn some C++, so I'm creating a simple Windows application. I was wondering, how can do I make items - such as textboxes, automatically move and resize according to the size of window. I know that in Visual Basic they use anchors, but how do I do it in C++? Has anybody got any examples I could borrow? Thanks
Asked
Active
Viewed 884 times
0
-
Have a look at this: http://stackoverflow.com/a/5739620/5987 – Mark Ransom Jan 09 '14 at 22:33
-
1It's **not about language but about library** (or no library) you're using to design your user interface. Plain Win32 API? Win32 + MFC? WTL? WT? OWL? QT? wxWidgets? Another one? – Adriano Repetti Jan 09 '14 at 22:33
-
It hadn't occurred to me to use a library... Which would you recommend? – Xanco Jan 09 '14 at 22:36
-
To ask for a library isn't a good question for SO (because everyone has his own preferences so it's just about opinion and pretty broad). It depends on your programming background and your compiler/IDE (mainly, IMO). – Adriano Repetti Jan 09 '14 at 22:39
-
I am using Dev-C++ and I have lots of experience with mark-up languages - from website production and games development - and I know my way around C-based languages - from games development and some software development. – Xanco Jan 09 '14 at 22:45
-
1@Xanco: He means that you _are_ using a library already to do GUI. You _must_ be. C++ itself doesn't have GUI features. – Lightness Races in Orbit Jan 10 '14 at 00:43
1 Answers
0
I presume that you are using Visual Studio.
FILE -> New -> Project
Select "MFC Application" and enter a name below.
You now get the "MFC Application Wizard".
Select "Application Type" from the list on the left.
Select "Dialog based".
Select Finish.
You now get a dialog that you can populate just like VB but it has created all the basic C++ code behind it so you can get experimenting.
To resize the controls with the dialog you must intercept the sizing message with a OnSize(UINT nType, int cx, int cy) call, use the class wizard to do this.
Good luck.

Oakdale
- 138
- 1
- 7
-
Looks like he's using Dev-Cpp. And there is no hint that he's using MFC. But nice try. ;) – Skalli Jan 10 '14 at 10:45