views:

510

answers:

8

When I create a 'Windows Forms Application', the resultant program is a managed one. Creating a 'Win32 Application' results in a native one, but when I try to add a form I'm informed that the project will be converted to CLI if I continue. How do I design a native Windows GUI with Visual C++ 2008 Express Edition? I'm probably being very silly here, but I just can't figure it out.

+1  A: 

You just need to avoid the managed libraries. Most likely, this will mean using MFC for the GUI, instead of Windows Forms. For details, see MSDN's MFC pages.

Unfortunately, VC++ Express Edition doesn't support MFC directly, so you'll have be more limited. It is possible to compile MFC projects using the Express Edition, but you lose all of the Wizards, etc. If you are serious about doing non-managed GUI development, you should consider upgrading to a higher level SKU.


Another option would be to use Qt for for GUI. It is now LGPL, so usable, for free, in even commercial C++ projects, and includes a full designer.

Reed Copsey
Thank you, but MFC isn't included with Express. I suppose I could just use wxWidgets or the like, but then that's not very 'visual'.
Dataflashsabot
It may not be visual, Reed does tell you how to do write a GUI C++ app with VS 2005 Express.
Binary Worrier
@Dataflashsabot: I'd recommend considering Qt, then. It's very nice for making native C++ GUIs, and does include a designer. I edited my answer to reflect this option, and included a link
Reed Copsey
A: 

You would need to use a native application framework. For Windows this means MFC or the bare Win32 libraries. WinForms use .NET libraries in the background and therefore need to be managed.

Joel
A: 

Native applications don't use "forms". For a native application, you could create, for example, an MFC application. If you want it to be something like a form-based application, you can tell the wizard you want a dialog-based application, or (on the last page of the Wizard) have your view derive from CFormView instead of CView.

Alternatively, you might want to use WTL -- though that means writing essentially all your code by hand instead of using wizards and such.

Jerry Coffin
The "Wizard" doesn't exist in Express Edition - unfortunately, MFC (and WTL) code is not supported (directly) in VC++ Express.
Reed Copsey
@Reed:I'll have to take your word for that. I played with the Express Edition at one point, and seemed to recall it's being able to create an MFC project, but 1) it could be my bad memory, or 2) something arising from my already having another edition installed. My recollection was that it only supported MFC in a DLL rather than statically linked, but that was the primary limitation.
Jerry Coffin
A: 

Windows Forms is the name given to the graphical application programming interface (API) included as a part of Microsoft's .NET Framework, providing access to the native Microsoft Windows interface elements by wrapping the existing Windows API in managed code.

Jive Dadson
A: 

As Reed Copsey, MFC would be the "default" way of creating a native unmanaged GUI on the Windows platform. However, MFC is not included with Visual Studio Express. Consequently, you would either need to upgrade to the full version or you could look into using a freely available C++ GUI library such as wxWidgets.

There is also wxFormsBuilder if you want a GUI editor.

You could also go down to the "bare metal" and code right to the Win32 API, maybe take some help from the common controls library. But you'll be entering a world of pain ;)

VoidPointer
Ah, I see. I was hoping there'd be a non-MFC native designer. I'll look into wxWidgets or qt. Thanks for all replies.
Dataflashsabot
There *is* a non-MFC native designer. It's called the Resource Editor.
Alex
A: 

Most of the above answers explain things pretty well - if you want to look into creating a pure Win32 Native App form (no MFC/WTL etc) take a look at the tutorials here: http://www.zetcode.com/tutorials/winapi/ for starters. That's the third time I've linked to this site on here, but his tutorials are very good.

Note - at this stage there's nothing "visual" about it except the result - it is all done in code, although that said I don't think it is too difficult really. It will definitely be good programming experience.

Ninefingers
A: 

Windows Forms are a GUI framework written in managed code, so you cannot use Forms in a native application.

With a native application, you have to create windows. Programming Windows by Charles Petzold is the definitive how-to book for this. It's a lot of work compared to using a good framework. MFC (Microsoft Foundation Classes) is a framework for native Windows GUIs. I don't know if it comes with VC++ Express.

Adrian McCarthy
+3  A: 

Either use MFC, WTL, or straight Win32 API. You can't use forms (or any of .NET) without switching into managed code.

John Knoeller
Adding to the answer - CreateWindow and DialogBox type functions may take a dialog template resource. You can use the resource editor to add new and edit using the graphical window editor.
Greg Domjan