Visual studio and C++Project

Thread Starter

skyr6546

Joined Mar 22, 2019
67
Can you tell me how do you create a desktop application project in c++ language

I followed the given link But I couldn't create a project successfully

upload_2019-4-23_22-14-52.png

I see some are using windows desktop or MFC or CLR so I don't understand which would best
 
Last edited:

MrSoftware

Joined Oct 29, 2013
1,601
I have the Professional version, maybe that's the difference.

The option you choose will depend on your requirements. What is it that you want your program to do? Full disclosure; GUI work is not my strong point, most of my experience is with lower level code.
 

Thread Starter

skyr6546

Joined Mar 22, 2019
67
The option you choose will depend on your requirements. What is it that you want your program to do? Full disclosure; GUI work is not my strong point, most of my experience is with lower level code.
@MrSoftware I want to create a scanner desktop application in c++ (GUI).

Have you created GUI in c++ (Desktop Application ) ?

What the option do you select in your application ?
 

402DF855

Joined Feb 9, 2013
111
I strongly recommend you start your application as an MFC Dialog based app, or alternatively, a C# Forms app. Avoid the newer WPF (Windows Presentation Foundation) and UWP (Universal Windows Platform); while C# based (usually), they rely too much on XML and are less intuitive than forms.

You may need to invoke the Installer to get MFC options installed. When generating a new app using the "New Project Wizard", if using MFC (which I recommend) make sure you select "Dialog Based" as opposed to Single or Multiple Document. The latter rely on the Document/View framework which add considerable complexity that's only worth the trouble if your app will be file driven (like Excel and Word).

You should not select "Empty Project" because you want VS to generate the initial code for you. And, there is no good reason to uncheck "Precompiled Headers".
 

MrSoftware

Joined Oct 29, 2013
1,601
What worked for me won't necessarily be the best choice for you, and it looks like you have some sound advice above. I would also suggest taking some time to learn basic GUI design principles and write some test apps before starting your main project. It may seem like it's using a lot of time at first, but it could save you a whole lot of time in the end, as an improperly designed GUI won't function well. The suggestion to also check out C# was a good one. With C# in Visual Studio you can design your GUI in xaml, then connect it to the C# code that does the actual work. This makes GUI development simpler and faster, in my limited GUI experience anyway. But if you must use C++, then these articles might help you understand why MFC could be the better choice:

https://docs.microsoft.com/en-us/cpp/atl/recommendations-for-choosing-between-atl-and-mfc?view=vs-2019

https://docs.microsoft.com/en-us/cpp/mfc/mfc-and-atl?view=vs-2019

https://stackoverflow.com/questions/7212051/whats-the-fundamental-difference-between-mfc-and-atl
 

Thread Starter

skyr6546

Joined Mar 22, 2019
67
I strongly recommend you start your application as an MFC Dialog based app, or alternatively, a C# Forms app. Avoid the newer WPF (Windows Presentation Foundation) and UWP (Universal Windows Platform); while C# based (usually), they rely too much on XML and are less intuitive than forms.

You may need to invoke the Installer to get MFC options installed. When generating a new app using the "New Project Wizard", if using MFC (which I recommend) make sure you select "Dialog Based" as opposed to Single or Multiple Document. The latter rely on the Document/View framework which add considerable complexity that's only worth the trouble if your app will be file driven (like Excel and Word).
Hello @402DF855 Thanks for the advice I am not interested in C# at this time I am interested to create GUI in visual studio using c++

Can you tell me the difference between MFC and CLR

Have you created any desktop application in visual studio using c++ for industrial automation?
 

Thread Starter

skyr6546

Joined Mar 22, 2019
67
What worked for me won't necessarily be the best choice for you, and it looks like you have some sound advice above. I would also suggest taking some time to learn basic GUI design principles and write some test apps before starting your main project.
https://docs.microsoft.com/en-us/cpp/atl/recommendations-for-choosing-between-atl-and-mfc?view=vs-2019

https://docs.microsoft.com/en-us/cpp/mfc/mfc-and-atl?view=vs-2019

https://stackoverflow.com/questions/7212051/whats-the-fundamental-difference-between-mfc-and-atl
I am interested to create a desktop application in c++ using visual studio for industrial automation

I have a time to learn basics that's why selected software tool : Visual studio and language : c++

I would like to know what type of app you have been developed for automation using visual studio and c++
 

402DF855

Joined Feb 9, 2013
111
Have you created any desktop application in visual studio using c++ for industrial automation?
Yes, many times.

MFC is a set of C++ classes that encapsulate the Windows API (e.g. Win32). A GUI project is composed primarily of C++/H files along with a solution (SLN) file, a project file (VCXPROJ) , and a resource file (RC). (The RC file contains dialog definitions along with string tables, images, etc.) The C++ handle details of windowing including windows messages which is the backbone of a traditional windows app. Before MFC the apps were written in C and were much more complicated. Visual Studio's IDE auto generates most of the base window messaging details so it was a huge improvement IMO in simplicity and efficiency. And MFC has been around for decades; I've written numerous industrial apps with it including laboratory test and data acquisition, and a wind tunnel control system, for example.

CLR came along with .NET. If you do any C# it will involve the CLR which is a layer that hides or replaces Win32. This is also called Managed Code. Until recently C++ was not supported with CLR but Microsoft has added that option. I looked at it and it seemed to suffer from what most of Microsoft's recent "innovations" in app development: unnecessary complexity. Apparently the explosion of phone and tablet development has prompted this decline IMO. But I did develop a C# CLR (Windows Forms based) app for a big name electronics company's production facility. It was easy to adapt to after years of using MFC, but I prefer the latter. I've tried to use the newer C#/XML/XAML projects but found them too counter intuitive and abandoned them.

So, I'd say MFC might be considered old school. The C#/heavy XML may be cutting edge. But I've seen evidence that Microsoft is perhaps ramping up support for MFC again.
 

Thread Starter

skyr6546

Joined Mar 22, 2019
67
Yes, many times.

MFC is a set of C++ classes that encapsulate the Windows API (e.g. Win32). A GUI project is composed primarily of C++/H files along with a solution (SLN) file, a project file (VCXPROJ) , and a resource file (RC). (The RC file contains dialog definitions along with string tables, images, etc.) The C++ handle details of windowing including windows messages which is the backbone of a traditional windows app. Before MFC the apps were written in C and were much more complicated. Visual Studio's IDE auto generates most of the base window messaging details so it was a huge improvement IMO in simplicity and efficiency. And MFC has been around for decades; I've written numerous industrial apps with it including laboratory test and data acquisition, and a wind tunnel control system, for example.
.
Hello @402DF855 Thanks for the detail description

so I want to create one button and when I click on the button "hello world " should be print

Is it the right option to create a project?
upload_2019-4-24_21-56-24.png
 
Last edited:

402DF855

Joined Feb 9, 2013
111
Sorry, not "Multiple Views" but "Multiple Documents". The "Dialog Based" option is far simpler and likely more appropriate for your project. I think Microsoft is proud of their Document/View framework so they make that the default, even though it is rarely the right choice. So start with the dialog based option and you can investigate the others later on.
 

Thread Starter

skyr6546

Joined Mar 22, 2019
67
Sorry, not "Multiple Views" but "Multiple Documents". The "Dialog Based" option is far simpler and likely more appropriate for your project. I think Microsoft is proud of their Document/View framework so they make that the default, even though it is rarely the right choice. So start with the dialog based option and you can investigate the others later on.
Hello @402DF855

There are more steps to create a project. can you tell me

Which option do you follow to create a project?

Find the attachment
 

Attachments

Last edited:

402DF855

Joined Feb 9, 2013
111
As long as you pick "Dialog Based" you can take the defaults for the rest of the project creation. If you want, you can modify the defaults, for class names and files, but this is not necessary.
 

Thread Starter

skyr6546

Joined Mar 22, 2019
67
As long as you pick "Dialog Based" you can take the defaults for the rest of the project creation. If you want, you can modify the defaults, for class names and files, but this is not necessary.
Hello @402DF855

I don't get anything in the tool box.

I need your help to create one GUI button if I click on a button it should display the message "Welcome"
 
Top