Windows GUI applications in VisualStudio - c++

What are the valid ways to write (hopefully native) C++ applications with GUI in VS 2010?
I remember some 10 years ago I was using MFC, any big changes today?

If you want to stay with Native API then MFC is still a good choice or plain Win32 API.
There are new controls like the ribbon control introduced in VS2010. There's a tutorial on native development with VS2010 on MSDN. There are also a lot of C++0x features available to your native program if you're using VS2010.
Qt is another good choice even if you aren't going cross platform but you won't be using VS 2010 most likely in that case. The licensing is now free for commercial use with LGPL.
If you are going to use a newer framework like WPF from Microsoft then you will need to use a managed language (.NET). Another choice is Silverlight for both web and apps. Silverlight apps have the advantage that you can get them to work even on Mac if they have Silverlight installed. Winforms is still easy to code but mostly superseded by WPF.
Unless you have good reason to do so, you can develop much faster with a framework like WPF instead of MFC. Even if you don't know a managed language. (If you don't go straight to C# instead of C++/CLI). WPF also offers GPU acceleration.

You can use Windows Forms, or Windows Presentation Foundation (WPF) - in VS2010 you can use either of these to create apps with a GUI. In terms of which would be the best - I suppose that depends on your specific needs, but I couldn't say as I've only really used WinForms. However, WPF apps seem to have more components for you to use.

Just for completeness - not advocating it, wxWidgets is a cross-platform GUI toolset.

If you really want native, and you really want C++, your best option is WX. MFC has some nice controls and such but still lacks any semblance of a complete UI library. It lacks any layout managers, period and still suffers from being a basic wrapper to the win32 C API. WX has some of this latter issue as well but has been cleaned up considerably from MFC and has layout managers.
A couple other options:
You could break out of C++ and go with one of the .NET languages to use other, better native libraries.
You could use a cross-platform library that'll still have the look and feel of the native toolkits, like Qt or GTKmm.

Related

Porting Objective-C app to Windows. What are the best options?

I have a fully-working audio/video application which is entirely written in Objective-C (with bits of C/C++ and GLSL).
I now need to port it to Windows and I'm wondering what my best options are. I'd like to stay in the C/C++ domain so Java is not an option.
I know that this will be a lot of work but I also want this to be good (attention to detail is very important to me, I subclassed many UI elements to suit my needs).
Currently, I think that I could either port the whole app to C++ and use Qt for the whole UI (I did some small projects with that and found it mostly ok) or I could port the application core and write two different UIs for Windows and Mac (the Mac UI is already there of course).
Has anyone of you done what I'm trying to do and can give any insight? What's the best approach and why?
I have almost zero knowledge of Objective-C and macOS UI, but on Windows I think the best C++ OO tiny and efficient wrapper around native C Win32 APIs is WTL, based on ATL.
There's a quality series on WTL on CodeProject.
In the realm of Windows-specific C++ frameworks/libraries, you may consider MFC as well (which offers good integration with Visual Studio IDE), but honestly I prefer WTL: it's kind of more lightweight than MFC.
In addition, there's the cross-platform Qt alternative you already cited in your question.

Modern, native way of creating WinAPI GUI apps in C++ [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
First, I know this is kind of common question, but I could not find the exact answer I am looking for.
I have done many projects in Java using Swing. Starting by just coding the GUI, then later moving onto GUI designers. This proved to be a very quick and easy way to build GUI apps.
But now, I need to move to C++. I am beginning a project which uses a lot of HW resources (DirectX, OpenCV, etc...) I know there are Java libraries for these technologies. However, C++ is definitely the right way to go, considering the internals of this project.
I know C and C++ languages well from MCU programming. Also, I have read many articles on native WinAPI programming, Windows internals, etc. I think I have enough knowledge to start. I don´t want to worry much about GUI design, but it must look appropriate.
I know there are few basic options: Pure WinAPI, MFC, WTL, Qt... I would be very glad if there were some kind of GUI designer tool, but from my research, there is not. There is the MFC wizard which helps to create a basic window, but it is not a designer. The closest thing I found was Qt. But from what I read, it is not using WinAPI for drawing, for in future look and feel of Qt written app can differ from native Windows look.
So, to summarize, please, if you are experienced with creating native Windows C++ Apps with GUI, what would you recommend to me? Specifically, is there any tool or designer I missed?
(I am using Visual Studio 2010 professional, since I have it free thanks to the DreamSpark project)
I recently used Qt4 and was very pleased with the API. I found it straightforward, well documented, and the code is extremely concise.
Qt does an extremely good job of emulating the target OS look and feel (as #In silico pointed out in the comments, Qt actually draws everything itself and does not use native components) Regardless, this can be coded by hand or visually through the GUI editor in their IDE, Qt Creator. If you go this route, I recommend creating your initial GUI project (.pro file) there, then importing it into Visual Studio via the Qt Visual Studio Add-In.
Slots and signals, Qt's event/messaging system, is also worth mentioning. Yes, it's critical to GUI programming, but could also be extremely useful in lower-level code.
I expect Qt would work well in your project, but as always, create a few simple tests to ensure the technologies will work together feasibly.
Here are a few hints:
Don't lock yourself into C++. C# and Java (for instance) can be easily interop'ed with C/C++. (Through PInvoke or C++/CLI for the former and JNI for the later). C++ may not be the ideal language to write a GUI quickly.
Your requirement for "native windows look" is arbitrary and you should think it over. Is that really what you need ?
Winforms. It's an older technology but is still widely used. You use the API from C++/CLI or C# (or any .NET) language.
WPF, a more recent API but that will be harder to deal with from C++, (better with C# or VB)
One of the many GUI toolkit available on the market that have a C or C++ API (QT, GTK, wxWidgets, the VCL, ... list here). Some have "native" looks, some don't. Some have designers some don't. Some are free, some aren't.
If you need simple user interface i recommend use WTL - is simple, lightweight, header-only library, very good wrapper over WinAPI. In Visual Studio you can use form designer for creating windows and use WTL classes for implement interaction with user. WTL have poor documentation but WTL is looking like MFC.
If you want rich possibilities i recommend use Qt. It's very powerful GUI framework with great community.
You can use the C++Builder XE2 (Part of the Rad Studio IDE), which includes the VCL (Visual Component Library), the VCL is a wrapper over the Windows controls (and also includes custom controls) which increase the development productivity.
The wxWidgets c++ class library comes with a screen builder.
VCL is a good way to go. It has a GUI designer tool (Embarcadero Rad Studio XE6) fully native gui developer for C++ and Delphi
Depending on how strict your definition is, you could use .NET Windows Forms or Windows Presentation Foundation and plug logic in from C++, C++/CLI, and C#. That would not be a pure C++ solution. In fact, I wouldn't even necessarily advise using C++ in that situation. Simply using C# would be more intuitive and maintainable. WinForms and WPF have pretty awesome GUI designers though.

GUI easy and fast without .NET framework?

Is there any way to build graphical interfaces in the same rapid and easy way we could do in Visual Studio, but without .NET Framework? I'm looking to native Windows GUIs, so using Qt with Qt Creator is not an option (and it doesn't need to be cross-platform). Something with the Windows API using C++ would be great (not Delphi).
I mean, applications like WinSCP really have its GUIs written entirely by hand?
Given:
You don't want to use Qt
You want to use Win API
The natural option is MFC. It's basically quite a thin wrapper around the Win32 UI API, but VS has an MFC UI designer that will save you a lot of work (no need to manually set the co-ordinates of controls etc.).
My vote is still on Qt.
I suspect OP is really confusing "Native" with "deployable in a single binary". You can achieve this also with Qt by statically linking Qt dependencies. Contrary to popular belief, the LGPL does not prohibit this either.
Now if OP is looking for "deployable in a single super small binary" utorrent style, the answer would differ. A discussion around small binaries seems a good place to look. I would say there is a price to pay in increased development time though.
But I can't agree on Qt not being as native as say MFC.
Another excellent option is C++Builder with the VCL. This is very similar to WinForms (whose design it clearly inspired) and much more productive than MFC in my opinion.
As both Qt and MFC are wrappers around the native OS functions for managing windows and other OS utilities (that use Win32 API under the hood and look completely native) there is really no reason to consider the use of MFC over Qt, as it is not more native than Qt. Either your definition of "native" is broken or you haven't told us the whole story.
But there are a thousand reasons for considering Qt over MFC, as the latter is a complete pain to use, whereas the former is a cleanly designed, easy to use and still highly flexible library (that strives for nativity by any means possible).
The only way you might see MFC as more native is that it comes from Microsoft (the same company that developed Windows). But that doesn't make it more native. It's still a third party library. This third party worked for the same company as the party developing the Win32 API, but that doesn't make it specifically more tied to the Win32 API, as both were developed independently (and surely by different people).
Do Qt apps look and feel native under Windows?
You could also take a look at wxWidgets.
In addition to MFC, you might want to look into the Windows Template Library.

What is the best way to get started in GUI C++ programming?

So, I learned C++ (fundamentals) and I want to write software, however I have stumbled upon a problem where I don't know where to get started. It seems like learning C++ was the easiest part by far when it comes to understanding the libraries for the GUI construction the concept I yet don't fully comprehend. I searched a lot and couldn't even decide been a new guy on MFC, Win32 or Qt.
Qt C++ GUI seems like a fun and easy to use software with the definitions of classes available right there quickly.
With Visual's MFC I am seeing a lot of code upfront on the pre made project file and a lot of description of classes, however getting definitions is a bit slower as I have to go to the internet.
Win32 is apparently written in C and is not updated much?
A lot of people recommend Java and C# as well, but I am not interested in learning a new language when I don't have C++ set in stone and practiced with enough yet.
Not sure how to go about this.
Go with Qt if you envision porting your program to platforms other than Windows and/or your actual UI needs are relatively straightforward. But Qt, being "fun," abstracts you away from the Windows API, so if you find yourself needing to access features of that API not offered by Qt, then you'll be up the creek. So go with MFC if you're staying on Windows and you're building an application whose complexity or Windows-specific features may require more direct access to the Windows API. MFC provides a thin abstraction layer over that API; its concepts map more or less one-to-one with the API's concepts.
What kind of GUI do you want? Any framework should be able to do any kind of GUI, but some are optimized for certain work:
MFC is optimized for making applications that edit documents, like MS Office programs Word, Excel, Powerpoint.
wxWidgets and Qt (and .NET WinForms and WPF) are optimized for any sort of app that primarily uses widgets (textboxes, buttons, menus).
SDL is optimized if you want to draw stuff, like graphs or vector artwork.
I wouldn't recommend that you use MFC since it isn't a good fit for most applications, and also doesn't use modern C++ design, it's loaded with workarounds needed for stuff that was broken in early versions of Visual C++ and now can't shake those workarounds because of backward compatibility.
The Win32 API is actually really useful to know regardless of what kind of application you want to make, because it defines the rules for how the UI interfaces to the rest of the system. Yes, it's written in C, but this is to make it usable from any programming language, not because it's an obsolete design. Win32 API is highly object-oriented and uses polymorphism extensively.
Few things you need to be aware of:
If one day you want to sell a program written using Qt you might need to purchase a license.
If you feel like GUI applications/ GUI programming is what you want to do in general, for windows platform you better learn WinForms or even better WPF (with C# of course).
If you just want to quickly put up simple GUIs for your C++ programs for learning purposes, and you don't care much about learning the frameworks and licensing issues, just go with Qt or wxWidgets.
MFC is outdated. If sticking with C++ on Windows, I recommend you to lean C++ CLI.
However I suggest you to learn c# directly since c# is the mainstream language in .Net world.
For GUI, the windows world is now dominated by WPF.

Advice for C++ GUI programming

I have been writing C++ Console/CMD-line applications for about a year now and would like to get into windows GUI apps. For those of you who have taken this road before, what advice/tips can you give me. Ex: good readings, tutorials, approach tactics, etc...
I know this is a really broad question, but i really don't know how/where to start, thus not knowing how to ask this question properly.
I highly recommend the use of the Qt Libraries for several reasons:
The Framework is freely available for Windows, Linux, MacOS X, and a couple of mobile systems. Since version 4.5 the license is LGPL, which basically means that you can use Qt even in commercial applications.
The design of Qt is out-standing, e.g. they use modern design patterns and a very consistent interface design (I don't know many other libraries that use object-oriented ideas in such perfection). Using Qt is the same as using Boost: it will improve your own programming skills, because they use such beautiful concepts!
They are bloody fast, for instance in rendering (due to the different back-end for OpenGL, DirectX, etc.). Just have a look on this video and you see what can easily be done with Qt but is hard to achieve with native Windows, Mac, or Linux programming.
They have a really great documentation, with tons of tutorials and a very good reference. You can start learning Qt easily with the given docs! The documentation is also available online, so have a look and see by yourself.
As mentioned before, Qt is cross-platform; you have one source-base that works on all the important operating systems. Why will you limit yourself to Windows, when you can also have Mac and Linux "for free"?
Qt is so much more than "just" the user interface; they also offer network and database functionality, OpenGL bindings, a full-working web-browser control (based on WebKit), a multimedia playback library, and much much much more.
Honestly, I wasted a couple of years by developing software natively for Windows, while I could have been so much more productive.
For C++ you have two choices, Native or Managed.
For native development, my team (at Microsoft, in Windows) uses the Windows Template Library. It works very well for us.
You should learn the basics of Win32 and how Windowing works. The canonical tome is Programming Windows®
For Managed development you can use C++ with Windows Forms. However, windows forms has been supplanted by Windows Presentation Foundation (WPF).
Here is a good site that can get you up to speed.
This tutorial is useful
You can use Visual C++ 2008 Express Edition for your tools (they are free).
My best advice for Windows C++ GUI programming is don't do Windows C++ GUI programming.
I realize that is an extremely uninformative/smartass response if it's not qualified, so I'll note that you don't state that you need to do C++ Windows GUI programming, but that you "Would like to get into Windows GUI apps." If that is the case, and you don't have a very specific reason to use C++ (i.e. gigantic existing legacy codebase written in MFC or a bunch of C++ code that you want to build a front-end for but would be a pain to expose to .NET code), then it is going to be a lot easier and more productive to go the .NET route and start learning Windows Forms or better yet WPF using C# or another .NET language of your choice.
If you do need to go C++, then I would second the recommendations for 3rd party toolkits like Qt or wxWidgets, as the state of C/C++ GUI programming tools from Microsoft is now abysmal.
Most windowing libraries and technologies use similar idioms. Pick one and learn it.
The Windows Template Library is a very nice veneer for Microsoft Windows while sticking with C++.
For cross platform C++ windowing toolkits (they work on Microsoft Windows as well as other platforms) you can try QT or wxWidgets.
Well, for the Windows GUI, get used to referencing the MSDN a lot, assuming you want to deal with the API directly.
My favorite resource for learning the basics was theForger's tutorial, but there are hundreds of books and other sites out there.
I guess an important place to start is your toolkit. You tagged this visualc++, so I assume you are looking at that, however remember there are other toolkits like Qt.
I would suggest starting at Microsoft's tutorials.
+1 for Qt. I would put documentation at the top of my list of requirements for a GUI system. Qt has great docs and there's a huge community behind it. Also there are several books about it. Good docs are extremely important if you are working alone with no other team members to rely on. Alternatives are wxWidgets, MFC, WTL, FLTK and many more. They all have pros and cons. Eg FLTK is small and only provides GUI whereas Qt and wxWidgets also include networking, database access etc. Qt seems to have the most momentum at the moment after the Nokia buyout eg the release of Qt Creator which enables you to develop apps outside of Visual Studio.
It has been so long since I worked with C++ on Windows GUI, my word is always avoid C++ in Windows GUI unless you have a very good reason, I mean a good darn reason, if you need some performance C# is more than enough for 90% of the cases, and if you need more power write your performance critical thing in a C++ dll, and call it from a Windows Forms or WPF application.
It will save you hell of a lot time.
Still my opinion, if you have another I totally respect that
The first question is that do you want to develop Free, Open Source, for personal use or Commercial applications in C++?
If you want to develop for personal use! Then you can go with some good C++ Toolkit, Framework or API.
If you want to develop an GUI application that will be open source or free. Then you can go with C++ Toolkits, Frameworks or API's that have the GPL or any open source license that fits your needs.
Even you can develop Commercial applications with open source toolkits, frameworks or API's that have LGPL license.
The second question is that do you want to develop for the Windows, Mac, Unix or Linux? or these all, even for the mobile platform?
If you have a Windows user, as I am, and want to develop only for the Windows, I mean not for the cross platform, you can go with Win32 API, although, learning Win32 API is harder but it gives you the complete control over the machine. Believe me that no other tool would you provide the complete control over the machine. If you dislike Win32 API, for any reason, you can go with MFC, which is another technology from Microsoft, but is not free, old and has less attention now a days. If you decide to develop with .NET platform, you have C++/CLI, an extension to C++ language for developing .NET applications. .NET gives you the type safety, OOP and a built in garbage collector, provides you the all API's related to Windows and x86 or x64 machine in one package.
.NET has its own world! Microsoft has decided to port .NET to other operating systems too, Mono project is an example... You can develop nearly all kinds of applications using .NET.
If you want to develop C++ GUI applications for the cross platform, then Qt, WxWidgets and U++ are available for your help. You can write once and deploy anywhere with these libraries. Many open source IDE's and compliers are also available to develop C++ applications with ease. Note that if you do not want to develop for the cross platform, any cross platform library would be overhead and unavoidable increase in size of the executables.
Is your C++ knowledge is good enough to program software systems?
In fact, if your knowledge of C++ is not enough deep and you do not understand programming methods like OOP, Encupsolation, Classes, Interfaces, Types, Programming Patterns and so on, you can not use any toolkit with full potencial.
Do not forget that every Toolkit, Framework or API is implemented in some programming language. If you do understand the language very well, you can use the toolkit very well. I think, you would understand my point.
Put aside WPF or VC++ or Qt, You can also try out several libraries such as :
OpenFrameworks
Processing
...
there's an active project for developing Gui with Openframeworks here:
http://www.syedrezaali.com/blog/?p=2172
Are you familiar with Microsoft Visual Studio and .NET technologies? Since you want to develop for Windows platforms why don't you start by taking a look at Microsoft Visual C++ Express Edition.? Explore a little with the available tools from MS and search for some tutorials.
We are in 2020 but the question is still pertinent. I agree with Qt users, it's a great framework.
However, there is also C++Builder that offers you design GUI visually at design-time. C++Builder application can be built on both VCL (Windows only) and FireMonkey (cross-platorm) frameworks. Clang compiler can produce both 32 and 64-bits native executables. Community edition of C++Builder is free. Delphi integration is seamless: C++Builder project can include Delphi files directly and use any existing Delphi component packages and libraries.