简体   繁体   中英

How can I add windows controls to a C++ desktop application in Visual Studio 2017?

I've started a new Visual C++ desktop application in Visual Studio 2017 and I'm having trouble getting started with the UI / View. I normally do Windows development in C# with WPF, but I've had to go with C++ for various reasons on this one.

This seems like a rookie question, but I can't see any obvious way to add basic controls, like a TextBox, Label, Button, or Canvas. Several hours of searching online hasn't yielded any concrete results either - only added confusion.

There's definitely a blank form there when I compile and run. It even has a Menu -> Exit.

Is there a specific framework I should be using, like Windows Forms or MFC? Are those even still supported? Do all the UI elements have to be added in C++ code? Did I choose the wrong type of Visual Studio solution?

More Info, by Request:

What I'm working on is a 3D modeling program, similar to something like Blender, but greatly simplified. I'll need to use the FBX SDK, which Autodesk publishes, but it only supports C++.

I've already started one version which uses C# / WPF for the front-end. The goal is to incorporate the SDK later with either some sort of multi-project solution or a dll that I've compiled separately. I haven't attempted something like this before.

The all-C++ version is my idea of trying to simplify everything by consolidating into one language, one project, and one solution. I think if I do a really basic alpha version each way, it will help me choose the best answer and be doubly-educational.

1)Is there a specific framework I should be using, like Windows Forms or MFC?

Using MFC in VC++ 2017, one can quickly using drag-n-drop, insert a number of window controls including ActiveX/COM components directly over dialog box. Thereafter a suitable class, interface events can be generated through in-built wizard. A variety of application choices SDI(Single-Document-interface)/MDI/Dialog based are available to start with.

2)Are those even still supported ?

MFC still works very well on VS 2017 and very user friendly, requires minimal coding IMHO.

3)Do all the UI elements have to be added in C++ code?

No. Let say you added some static text, accelerators, buttons on a dialog and generate a class with a single line of coding. You just insert the appropriate control events and invoke window messages suitably.

4) Did I choose the wrong type of Visual Studio solution?

Don't arise. Worked with MFC in 2010,2012,2015 and 2017, most of the MFC codes remains same. But some conversions are required when one have to switch from multibyte to unicode style.

Hope it helps a bit to clear your doubt. The window controls can be skinned pretty easily.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM