Do I have to use "Visual" C++ in VS 2008? - c++

I am new to Visual Studio 2008 (.NET Framework 3.5) and am Developing a Windows Form application.
Starting the IDE, the only options for a New Project are under the categories:
Visual Basic
Visual C#
Visual C++
I did Visual C++ -> CLR -> Windows Forms Application
However, the template code is in the "Visual C++" syntx.
How do I create a new GUI project with plain vanilla C/C++ using Visual Studio 2008?
Please note, the last time I did this was with MFC in Visual Studio C++ 6.0
If I am missing the underlying principal please explain.
Thank You!
Example: http://msdn.microsoft.com/en-us/library/ms235634%28v=vs.90%29.aspx

Long story short - you cannot.
Windows Forms is a .NET framework and not a C++ framework. This in turn means that you cannot use C++ to work with it. What Microsoft did is invented their own language that is C++-ish, but compiles into CLI bytecode (likely with native code mix-in, but I am not sure). Before it was "Managed C++", now it is C++/CLI (what you have linked as an example is not C++, but C++/CLI).
For plain C++ projects you have to choose "Win32 Project", "Win32 Console Application" or "Empty Project".. But then you cannot work with Windows Forms. Your options would be to use other GUI libraries like GTK, Qt, WxWidgets. There are tons of GUI frameworks. Or perhaps you would prefer sticking with Win32 API. My personal choice is Qt. And no Visual Studio at all.
Hope it clarifies things a bit for you. Good luck!

The "Visual" is just the name of the product. It's not a different language. c++/cli however, is a different language, and that's what you're seeing. If you want to make a Windows Form application, you will have to use .net. C++/cli is a .net language, C++ is not. You can make actual C++ applications with Visual C++, just not Windows Form applications.

First, there is no such thing as "Visual C++", in terms of a language. There is C++/CLI, which is a sort of variation of C++ that has extensions for building .NET libraries and programs using a C++-like language.
Windows Forms is a technology based on the CLR: common language runtime. AKA: .NET. You cannot build a Windows Forms application with just ISO C++. At some point, you have to talk to the CLR, which is at minimum going to require some COM support. And you'd probably be better off with C++/CLI and doing it that way.

Visual in this case means Windows Programming. And that include designing GUI (Graphical User Interface) for your application which will work in Windows environment. The language itself is C++.
You have two options available to develop Window Application.
Use Window API's only
Use a frame such as MFC,WPF etc
The language is always C++ but it has accommodation for Windows and therefore Visual C++.
Btw if you want plain C/C++, choose Visual C++ and start a console application. Make sure you select empty project.

Related

C++ UI alternatives in visual studio 2013

C# is my primary language, I want to learn C++ but with windows form or any GUI, just not console. I read that they took windows form out of visual studio 2013 for C++. Are there any alternatives or workarounds? How are people making UI based C++ programs in vs 2013 now? I found this but it feels like a jerry rigged approach http://www.bogotobogo.com/cplusplus/application_visual_studio_2013.php. I would like to use VS 2013 and UI forms somehow.
There answer is there is no native solution. You'll need to use an open source framework like Qt, wxWidgets, etc. I would recommend Qt, as it does have an LGPL license option and their form builder integrates within Visual Studio.
You can use Code to gui which is easy to setup and use with Visual Studio and c++. Although it doesn't gives too many gui features like qt as of now but seems like a great option for learning c++ with basic form builder gui.
PS: It internally uses wxwidgets so you can also re-program it's internally generated files to make complex guis.

Confused about Microsoft C++ offerings and terminology

I'm using C++ for the first time since pre-.Net days and I'm confused about some of their C++ offerings and how they name them.
Prior to .Net, Microsoft supported a language called C++ which was pretty close to the industry standard. But when they introduced .Net they add a lot of extensions to their C++ and called it "Managed C++".
Then in 2005 they dropped that and replaced in with "C++/CLI" which is a version of C++ that conforms to Microsoft's (ISO-certified) Common Language Infrastructure and has some syntax changes (e.g., ^ instead of * for pointing to .Net objects, etc). C++/CLI can be compiled down to the platform-neutral Common Intermediate Language (CIL). At runtime this is processed into machine code by the Common Language Runtime (CLR). Here's a diagram from Wikipedia:
http://en.wikipedia.org/wiki/File:Overview_of_the_Common_Language_Infrastructure.svg
Here's where I get confused:
In Visual Studio 2010 Professional I don't see the term "C++/CLI" anywhere, even though that is supposedly what Microsoft is offering. If I do File->New->Project->Other Languages it lets me select "Visual C++"
1. What is "Visual C++" and how does it relate to C++/CLI?
At the top level of "Visual C++" it lets me create an "Empty Project" and in the Project Properties for it, Common Language Runtime is set to "No Common Language Runtime Support"
2. Does "No Common Language Runtime Support" also mean no CLI/CIL and thus no C++/CLI syntax? In other words does the state of that setting determine whether this is "C++/CLI" or just plain old unmanaged C++?
Underneath "Visual C++" it also has entries for CLR and General. If I make a CLR Empty project I notice that Common Language Runtime is set to "Common Language Runtime Support /clr"
3. Is that the only difference between a Visual C++ empty project and a Visual C++ CLR empty project?
4. What is a Visual C++ "General" empty project?
5. Is all this stuff documented/explained somewhere?
EDIT: Since posting my question I've noticed that it's even more complicated. The default properties for Common Language Runtime vary on different templates under the CLR node from CLR to CLR with "Pure" MSIL to CLR with "Safe" MSIL. And that's just that one "Common Language Runtime" setting. Does Microsoft document these templates anyplace?
The Wikipedia article on Microsoft Visual Studio says:
Microsoft Visual C++ is Microsoft's implementation of the C and C++
compiler and associated languages-services and specific tools for
integration with the Visual Studio IDE. It can compile either in C
mode or C++ mode. For C, it follows the ISO C standard with parts of
C99 specification along with MS-specific additions in the form of
libraries. For C++, it follows the ANSI C++ specification along with
a few C++11 features. It also supports the C++/CLI specification to
write managed code, as well as mixed-mode code (a mix of native and
managed code). Microsoft positions Visual C++ for development in
native code or in code that contains both native as well as managed
components. Visual C++ supports COM as well as the MFC library. For
MFC development, it provides a set of wizards for creating and
customizing MFC boilerplate code, and creating GUI applications using
MFC. Visual C++ can also use the Visual Studio forms designer to
design UI graphically. Visual C++ can also be used with the Windows
API. It also supports the use of intrinsic functions, which are
functions recognized by the compiler itself and not implemented as a
library. Intrinsic functions are used to expose the SSE instruction
set of modern CPUs. Visual C++ also includes the OpenMP (version 2.0)
specification.
So, I can have a go at answering your questions (which, by the way, are too broad):
Microsoft Visual C++ (often abbreviated as MSVC or VC++) is a commercial (free version available), integrated development environment (IDE) product from Microsoft for the C, C++, and C++/CLI programming languages. It features tools for developing and debugging C++ code, especially code written for the Microsoft Windows API, the DirectX API, and the Microsoft .NET Framework.
I'd say yes.
I'd say yes, but that is a big difference in itself, even if it is the only one.
I don't know exactly. I guess an empty project is a project which is designed so that you add your own stuff to it. "General" probably means that the project is not of any specific kind.
Microsoft has tons of documentation on MSDN, but has a long tradition in confusing people between the real C++ and their own managed C++-ish language, whatever they call it today. (I have always thought that this is bad, because C++ is C++ and there are lots of names out there for your new language, and that they've done it on purpose to gain clueless users. But this last sentence is an opinion, so it doesn't belong here. Hence the brackets.)
Does "No Common Language Runtime Support" also mean no CLI/CIL and thus no C++/CLI syntax? In other words does the state of that setting
determine whether this is "C++/CLI" or just plain old unmanaged C++?
Yes it means.
When you select "Create a new project" you can select (something as) "CLR Console Application" It means C++/CLI console application.
Also you can create Managed C++ console application if in the project properties you select option as
(something as) "CLR-support, old syntax (/clr:oldSyntax)" (I have Russian edition of MS VS 2010)

Native C++ programs in Visual Studio

I'm confused in my understanding of the relationship between Visual Studio and .NET. I want to write a C++ application, but not a ".NET C++" application. By this, I mean that my understanding is that everything built in .NET land gets compiled to a CLI-compatible intermediary code (just like "JVM" languages like Java and Groovy compile to the same bytecode).
But I don't want my app compiled to an intermediary bytecode...I want it compiled down to raw binary!
Does Visual Studio do this? Or is .NET forced down my throat the minute I choose VS as my C++ IDE? If so, whats a "raw C++" alternative to VS?
Thanks in advance!
Visual Studio is an IDE, which is orthogonal to any specific language or compiler.
Visual C++ is a compiler that supports the C, C++, and C++/CLI languages.
In Visual Studio, create a Visual C++ project from one of the 'Win32' (as opposed to 'CLR') project templates and your program won't have any .NET dependency.
there is that /clr compiler switch when compiling a c++ app. Without it, you will get a pure native binary and cannot use any. NET specific features within your code.
By selecting a project template or by setting the corresponding project property, VS will automatically choose if the switch is on or off.
Visual Studio still supports 100% native C++ applications as will as managed applications. When creating a new app just choose the "Win32 Console Application" to create a native application. For existing applications you can change / verify by doing the following
Right Click on the project and select "Properties"
Navigate to Configuration Properties -> C/C++
Make sure that "Common Language Runtime Support" is set to "No Common Language Runtime Support"

Using Visual C++ for C++ instead of C++/CLI

I know how to program in C++ making console programs, but now I want to code programs with interfaces for Windows. MS VS 2010 makes things easy when coding C++ Windows applications with its drag & drop design system. (.net Framework) However, Visual Studio seems to use C++/CLI, which I'm unfamiliar with.
Is there for an IDE which only uses C++? Is there any good IDE with an easy to use GUI designer, or can I tweak VS 2010 to not to use C++/CLI?
Visual C++ is perfectly happy to not use C++/CLI syntax, in fact it works even better without it.
Just set "Use of .NET Framework (/clr)" setting in your project options to "No". Or use the "Win32 Application" wizard when creating your project to begin with.
The "native" version of the Forms Designer is called the Dialog Editor and it works much the same way -- you can select textboxes and buttons and things from a palette and drag where you want them in your window.
The best RAD C++ tool, which also happens to accept unmanaged C++ is "CodeGear C++ Builder"
How about Qt Creator - IDE for Qt? http://www.qt.io/ide/

Visual C++ Development

I'm learning C++, and know a little bit of Visual Basic and an Delphi.
But I want to know, is there some program like Delphi, but for C++. Something where you can drag a button to a form, double click it, the like in Delphi and VB: opens a code editor and you edit the code of the button, but with a similar code of C++?
I'm using Windows Vista.
Yes, if you use MFC within Visual Studio.
MFC is Visual Studio's C++ class library for writing Windows programs, and for an MFC form Visual Studio behaves exactly as you describe.
As of Visual Studio 2008 with an upgrade pack you can create Office 2007 style applications, and Visual Studio style applications, using MFC.
There used to be "C++ Builder", a C++ version of Delphi, I don't know if this product is still being developed or not.
UPDATE: to summarize information from the comments, C++ Builder is actively developed and the product page is http://www.embarcadero.com/products/cbuilder/
You can have the following IDEs with GUI designers for free;
Visual Studio 2008 express from Microsoft
Qt Creator from Nokia
Eclipse with Qt plugin from community :)
C++ Builder from Embarcadero
(previously CodeGear, previously
Borland)
Have fun with C++!
There are other packages besides MFC that do GUI stuff, but I don't think they plug-in to Visual Studio. I must confess, I have never been a fan of MFC. I find it ugly and painful, so I can't really recommend it.
Qt has a designer, as does GTK. I haven't used the Qt designer, but the GTK one works well. It can be found here: http://glade.gnome.org/ You can get glade for Windows here: http://gladewin32.sourceforge.net/
It can be hassle to set these up, though.
Honestly, while I like C++ a lot, writing GUIs for Windows is not where it excels. I would recommend that you look at C# instead. You can still interface with C++ if you need to, but it makes writing Windows GUIs so much nicer.