开发者

How do I create a non managed Windows GUI in Visual C++?

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 a开发者_StackOverflow社区dd 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.


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

  • MFC is Microsoft Foundation Classes - the most common C++ windows library
  • WTL is Windows Template library - a better C++ windows library IMO
  • Win32 is CreateWindow, DialogBox, etc, everything else is a wrapper around the Win32 api.


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.


This is an answer to the linked question. Unfortunately, that has been closed by Robert Harvey because he thinks it is a duplicate. It is not, sorry Bob.

The best library for creating xll's is http://xll.codeplex.com. You can use that to create rudimentary user interfaces using Excel macros. One example of that can be found in the ALERT.FILTER macro in xll/error.cpp


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 ;)


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.


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.


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.

  • Wikipedia


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.


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.


I noticed that no one mentioned JUCE which can be used to build cross platform user interfaces in C++. I thought it was pretty cool. Looks like it's been expanded to support mobile devices too since I used it.

Personal and Educational licenses are free. 'Pro' and 'Indie' licenses are relatively cheap.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜