Sign in to follow this  
Mantear

GUI Programming - Visual Studio 2008 and C++

Recommended Posts

Greetings! I consider myself fairly competent when it comes to C++ and I've recently installed Visual Studio 2008. For my work I mainly develop on FPGAs, DSPs, and embedded GPPs so I haven't kept very current with regards to modern Windows programming. I was hoping to use Visual Studio 2008 to do some simple GUI programming. All I really need to do is create simple apps (just a couple dialog boxes?) that I can connect to other devices (via UDP, serial port, etc), and send and receive information. I've normally done this through simple console apps and text based menus, but I want to make things look a bit nicer. However, in when I try to put something together in Visual Studio, I get a bit lost. It's either C#, or C++ .NET, etc. I was hoping there was something a bit more native C++. Back in college I used Borland Builder for C++, and from what I remember (which could be a little hazy), it was pretty simple to make a GUI that talked C++. Is there anything like that now, or am I going to have to dive into the world of .NET? I don't have a lot of time to devote to learning a new language which is my main reason to trying to stick with C++. Any suggestions are welcomed. Thanks!

Share this post


Link to post
Share on other sites
Quote:
Original post by Sc4Freak
Well, you can use C++, but I'd really recommend a slightly more sane language such as C# if you're making a GUI.


Seconded. You'll be gaining nothing from using C++ and the code is absolutely horrendous, it needs to be seen to be believed.

I would second C#, or VB if you fancy something a little easier going although C# in itself is a great language.

Share this post


Link to post
Share on other sites
Maybe it's time to dive into WPF (.NET only) which is very nice. It's so much more fun making GUIs in WPF than it is in anything based on the current aging UI framework.

Share this post


Link to post
Share on other sites
Quote:
Original post by MantearBack in college I used Borland Builder for C++, and from what I remember (which could be a little hazy), it was pretty simple to make a GUI that talked C++. Is there anything like that now, or am I going to have to dive into the world of .NET?

I used C++Builder too. Was nice. There is no such RAD features for native C++ applications in Visual Studio 2008.
But you can make an MFC (native) application easily, because the dialog editor may be enough for you, and if you're skilled enough to really master the C++ language, then it will be pretty straightforward for a tiny app.
If you want to make something bigger with Visual Studio and want a easy and powerful GUI editor, you need .NET (managed), so you need to use either C# or C++/CLI, and I warn you, C++/CLI is really a pain even if you already know C++ (I tend to think it's a different language and not just an extension), and you'd better learn C#, it won't take more time. C++ to C# is straightforward, just read this carefully. Use C++/CLI for managed<->native interop only (if you need it).

Share this post


Link to post
Share on other sites
Quote:
There is no such RAD features for native C++ applications in Visual Studio 2008.


That's not true. My original statement still stands. You can design dialogs in the resource editor and use it from Win32 apps quite nicely. If he doesn't want to spend time learning C#, that's fine; it's his prerogative. Let him use what he wants.

Share this post


Link to post
Share on other sites
Hey Mantear...what company do you work for if I might ask. I work on high level synthesis tool that takes in MATLAB and outputs VHDL/Verilog for FPGA's. Anyway...if you know C++ and that's what you want to stick to just go and read up on MFC and/or Qt. It'll get the job more than done. No sense in learning a new language if you are just trying to whip up a quick GUI.

http://www.codeproject.com was a good place for myself and buddy that did a lot of MFC stuff.

I personally prefer Trolltech's Qt...but that's just me.

My 2 cents for what its worth.

Share this post


Link to post
Share on other sites
Not quite answering your question, but Borland has recently released a new version of Turbo C++. Like the others, I strongly recommend C# + WinForms or WPF for this stuff, but I though you might be interested in checking out the Borland stuff. I haven't used it, but it claims to be "the only truly Rapid Application Development (RAD) C++ tool for the native Win32 platform."

Share this post


Link to post
Share on other sites
The closest thing you'll find in VS2008 for C++ is winforms.
I used it to make simple GUI for a lottery number maker program I did in my C++ class and it didn't take much work.
It has the same drag and drop GUI controls and stuff as if you were creating a winform app in VB or C#. The code used is Microsoft's bastardized C++ called managed C++ or CLI though. I stuck with standard C++ and the STL and it worked fine for me though. A lot easier than trying to learn MFC or straight up Win32 the only other common alternatives from Microsoft for C++!
Yeah it'd be way easier and faster to do in VB or C# but if you don't already know them languages and don't have time C++ Winforms is the way to go.
Here is video that should give you enough of the basics to get started:

Building Windows Forms Applications with Wizards in Visual C++ Express (12 Minutes - 8.2 MB)

This video will take you through the steps for creating a new Windows Form application using the wizards available in Visual C++ Express. The steps include naming the project, choosing the appropriate settings, adding controls, adding event handling code, and building and running the application that was created. After following these steps, you should have familiarity with how to add additional controls and event handling code to create a more robust Windows Form application.

You can check out the rest of the video's and some MFC ones if you decide to go that route which not even Microsoft uses so I'd avoid it unless you have no choice!


"So, what does MS use?
Almost all current Microsoft products are written in VC++. Very few use MFC. Some newer projects are being done in C# and C++/CLI.

I don't think it was ever a huge secret that MFC never caught on significantly within Microsoft."


Anyways, there are video's on using win32,mfc,winforms, and atl on that link I provided so you can decide for yourself.

[Edited by - daviangel on July 8, 2008 3:48:04 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by ArmitageIII87
I personally prefer Trolltech's Qt...but that's just me.


Just keep in mind that Qt is not free for commericial use:Qt Licensing

If you where previously into MFC, it might be worth checking out the new controls Microsoft just released in the Visual C++ 2008 Feature Pack:

Get a feel for the new MFC features using samples
Visual C++ 2008 Feature Pack Released!

You can still design Win32 dialogs in VS 2008 as Mike said. However, you could probably build the same app with C# in a fraction of the time. Mainly because the .NET Framework wraps up many of the tedious tasks.

Share this post


Link to post
Share on other sites
Quote:
Original post by rolkA
There is no such RAD features for native C++ applications in Visual Studio 2008.
Quote:
Original post by daviangel
The closest thing you'll find in VS2008 for C++ is winforms.

Wrong.

You can use ATL. I'm surprised nobody in this thread has even mentioned it.

The ATL dialog editor is much like the WinForms editor. You drag and drop controls, change their properties, and assign event handlers. This is what I use for my own C++ projects.

Unfortunately the ATL designers aren't available with VS express. I know they come with VS professional.

Screenshot

Example on CodeProject

Share this post


Link to post
Share on other sites
Quote:
Original post by Ra
Quote:
Original post by rolkA
There is no such RAD features for native C++ applications in Visual Studio 2008.
Quote:
Original post by daviangel
The closest thing you'll find in VS2008 for C++ is winforms.

Wrong.

You can use ATL. I'm surprised nobody in this thread has even mentioned it.

The ATL dialog editor is much like the WinForms editor. You drag and drop controls, change their properties, and assign event handlers. This is what I use for my own C++ projects.

Unfortunately the ATL designers aren't available with VS express. I know they come with VS professional.

Screenshot

Example on CodeProject

I was purposely talking about VS2008 since that's what the OP mentioned he was using:

"
ATL Server is no longer under active development by the Visual C++ team and will not be included in VS2008 or any future version of Visual Studio. Future development of ATL Server will be done as part of a shared source project on CodePlex.com, http://www.codeplex.com/AtlServer/. If you are interested in contributing to this project or wish to request a new feature in this version of library, please contact the coordinators of the project on CodePlex.com.
"

Noone mentioned it because there is no use beating a dead horse. It'd be like recommending MDX...
Besides if you went the ATL you are putting another prereq i.e. COM that the OP has to learn.

[Edited by - daviangel on July 8, 2008 3:21:19 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by daviangel
I was purposely talking about VS2008 since that's what the OP mentioned he was using:

"
ATL Server ...
"

Noone mentioned it because there is no use beating a dead horse. It'd be like recommending MDX...

They've discontinued ATL Server, not ATL. ATL exists in VS2008, along with all its wizards and designers. I am currently using it.

Share this post


Link to post
Share on other sites
You absolutely don't need anything (apart if you can't program)
In a few lines of C ou C++ code and Win32 api, you can do everything in a few minutes.
Especially for Dialog Boxes, you just have to use the Dialog Editor... and draw.
Only kids use external libraries for so basics tasks !

Share this post


Link to post
Share on other sites
Quote:
Original post by george135
Only kids use external libraries for so basics tasks !


Unless, you know, you want to do stuff which someone has already rewritten and don't fancy remaking it.

To the OP;
If you have the time picking up C# can be worth while. With basically no experiance with the language I knocked up a C# + GDI+ app on sunday night to begin testing some stuff (including dragging things around with the mouse).

It really is easy if you've got C++ experiance and experiance with doing GUI stuff in general.

Share this post


Link to post
Share on other sites
Using the Project Wizard to create a Win32 Application is the way to go. You can get it to generate the basic skeleton for you in seconds. All you have to do next is add some controls to your dialog (with the dialog editor.) and then write the code to make it do stuff. The process is super easy.

I think using C#, .NET or MFC for a task this simple is overkill.

Share this post


Link to post
Share on other sites
Quote:
Original post by daviangel
Besides if you went the ATL you are putting another prereq i.e. COM that the OP has to learn.

Please refrain from discussing libraries you have never used. For basic dialogs no COM knowledge is necessary, and no COM objects or code are even generated.

Quote:
Original post by AAA
Using the Project Wizard to create a Win32 Application is the way to go. You can get it to generate the basic skeleton for you in seconds. All you have to do next is add some controls to your dialog (with the dialog editor.) and then write the code to make it do stuff. The process is super easy.

You cannot use the dialog editor with the autogenerated window code in a Win32 project.

[Edited by - Ra on July 8, 2008 12:07:20 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Hodgman
Quote:
Original post by ukdeveloper
...and the code is absolutely horrendous, it needs to be seen to be believed.
I thought you were talking about the auto-generated C# dialog code for a second there - I can't stand the sight of that stuff!


I'm not sure what you mean, it's just a class? I don't think it looks all that bad but it's sure nicer than C++.

Oh, if you're wanting hideous auto-generated code, you might want to try XNA. Oh my good God that's horrible, it makes kittens cry and the whole structuring, auto-generated code and forced shoehorning of code into specific places are just a small number of the reasons why I dislike XNA. But that's for another day.

I haven't done attempted any C++ GUI programming since the days of VC++6 and even back then it was a deadly cocktail of epic phail and disaster [grin] and judging by what I'm reading here it sounds like things have both improved and got easier since those days. I always remember looking at the Win32 API and bemoaning the million and one lines of code needed to do anything, so I thought I'd try and save time by using MFC and threw up at the sight of it.

Share this post


Link to post
Share on other sites
So I got a couple of minutes to try a few things out and it looks like the MFC application is going to be the winner for me. Sure it's a little tedious, and a pox be upon you if you don't play nicely with the resource editor, but it lets me get done what I need to get done in a timely manner.

Thanks for the input everyone!

Share this post


Link to post
Share on other sites
Quote:
Original post by Ra
Quote:
Original post by daviangel
Besides if you went the ATL you are putting another prereq i.e. COM that the OP has to learn.

Please refrain from discussing libraries you have never used. For basic dialogs no COM knowledge is necessary, and no COM objects or code are even generated.

Quote:
Original post by AAA
Using the Project Wizard to create a Win32 Application is the way to go. You can get it to generate the basic skeleton for you in seconds. All you have to do next is add some controls to your dialog (with the dialog editor.) and then write the code to make it do stuff. The process is super easy.

You cannot use the dialog editor with the autogenerated window code in a Win32 project.


I never claimed that the dialog editor generates code for you in Win32 apps. All I said is that a basic skeleton app is auto-generated.

Handling events in pure Win32 is a simple matter and I never felt the need for VC to generate that code for me. But to each his own.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this