2

I'm developing my first Windows desktop application and I'm trying to figure out what the best approach would be to create the program's GUI.

I know, I know... I feel stupid for asking considering the amount of data on the subject on SO. However most answers seem outdated and I'm not sure if they fit my specific project. Also tutorials for Windows 8 'metro apps' are clogging my Google search results, which is NOT what I'm looking for.

I use Visual Studio. I've followed tutorials. I have basic knowledge of C and Java and extensive experience with PHP. I'm excited to learn C++, so I'm not looking for GUIs to create a GUI (like WinForms). I also don't care about managed code and portability for now, especially since I'm trying to avoid dependencies (i.e. users having to install .NET). As long as it runs smoothly on Vista and up, I'm happy.

The application

The software will teach basic physics to kids. I'd like to create a main area and a sidebar. The main area will feature a physics animation, say a bouncing ball, along with some Q&A. Users can zoom in to the animation to measure some stuff and answer the question. Users can track their progress in the sidebar. That's pretty much it.

What I've found so far

I'm getting a bit frustrated with MSDN. Most of their examples are given in four different languages (C#, C++, etc). I can't seem to get more than a bit of Hello World code from them.

I found a GDI API on MSDN and it seems like a good start for me. However I've read quite a few answers on SO saying creating layouts in pure C++ is really hard, that we're better of using frameworks like ATL and WTL. Since I'm also going to create (somewhat interactive) animations, I've wondered whether I should use gaming-targeted APIs like Direct2D.

Since all of this is new to me, and there are a lot of options, I don't know where to start for my particular application. Any tips would be greatly appreciated!

Robbert
  • 5,063
  • 6
  • 36
  • 44
  • Using GDI to create a GUI sounds like a waste of time. You can construct your UI visually in VS even if you don't use MFC, WPF or anything like that. – Michael Feb 14 '14 at 13:28
  • I wouldn't avoid .Net outright. C# is way easier to learn than C++ and .Net v3.0 shipped with Vista. – Peter M Feb 14 '14 at 13:32
  • 1
    Thanks for chiming in Michael. I'm afraid to use GUIs to create GUIs. I forgot to mention I've created iOS apps before using Xcode's Storyboard and it totally messed up the code. In the end I was better of hardcoding the GUI. – Robbert Feb 14 '14 at 13:32
  • Thanks, Peter. I'll have another look at C#. Considering my background I don't think either language will be hard for me to learn. – Robbert Feb 14 '14 at 13:40
  • @Robbert To paraphrase Scott Meyers (who I'd recommend reading if you go down the C++ path), `C++ is an amalgamation of 4 separate languages`. So don't underestimate the effort needed to properly learn C++ – Peter M Feb 14 '14 at 14:29

5 Answers5

9

Using the raw Win32 API (no additional downloads or third-party helpers):

Here's a good primer (introduces dialog boxes, text boxes, buttons, etc): theForger's Win32 API Tutorial

And here's where you go from there (numeric up-downs, list boxes, combo boxes, tooltips, and more): Common Controls on MSDN. Most of these require you to #include <commctrl.h>.

I also found this to be a good resource that covered what the other two didn't: Win32 Developer - Window Assets

But the Win32 API doesn't seem like it does exactly what you want. A physics app for kids should have a more visual GUI than the API can provide. Good luck, though!

Proxy
  • 1,824
  • 1
  • 16
  • 27
  • Thanks, Proxy. This is what I was looking for in the first place - raw Win32 GUI stuff. Definitely gonna read those articles. But like you said, it probably won't help with the physics part. – Robbert Feb 14 '14 at 14:00
3

If you're ok with adding additional Frameworks, I'd suggest looking at Qt.

It allows to create the GUI from code only, has a good structure, and has an Interface for 2D drawing, if required.

If you are concerned about dependencies, you only have to include the Qt DLLs to your executables; no installation is required for the user.

Aykhan Hagverdili
  • 28,141
  • 6
  • 41
  • 93
MatthiasB
  • 1,759
  • 8
  • 18
  • Thanks for your answer Matt. A lot of answers on SO suggested Qt for basic GUIs, but I didn't know it could do 2D animations too. I'll be creating (pre-coded) vector animations where users should be able to zoom in and out of. – Robbert Feb 14 '14 at 13:28
  • I was indeed concerned Qt would require a double setup like .NET applications do. Thanks for clearing that up. – Robbert Feb 14 '14 at 13:29
  • In my Qt applications. I install Qt and the MSVC runtime for whatever version of Visual Studio I built the application with directly in the NSIS installer I create for the application. My users do not have to download or install an extra package themselves. The Qt part of the installation is just copying a few Qt dlls to the application's bin folder. The MSVC runtime involves executing the appropriate installer for the Visual Studio runtime. – drescherjm Feb 14 '14 at 13:37
  • Qt has an interface to OpenGL, so it would allow any 2D or 3D applications. But I'd suggest looking at the examples, there should be easier ways to achieve what you want to do. – MatthiasB Feb 14 '14 at 13:38
  • Interesting stuff. Now I'm wondering why .NET applications don't include the .NET setup in their installer. – Robbert Feb 14 '14 at 13:43
  • Possibly to reduce the size of the download. – drescherjm Feb 14 '14 at 13:51
  • Valid point. Either way, thanks Matthias. I think Qt will provide a solid starting point for me considering the 2D animation aspect of my project. Marking this as best answer. – Robbert Feb 14 '14 at 14:02
0

To get started, see my (old) tutorial "Lessons in Windows API Programming".

But you really need a good book, such as edition 5 or earlier of Charles Petzold's classic "Programming Windows".

The problem with latest edition is that it's for C# and .NET, with Charles grabbing the tail of the "new way" at just the wrong time…


Disclaimer: I haven't checked the details of edition numbers.

Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331
  • Thanks for the quick reply Alf. I've been looking at books, but like you said, quite a few of the new books are about C#/.NET and the older books seemed outdated to me. I'll definitely look into your suggestions. – Robbert Feb 14 '14 at 13:25
0

Using the Windows API is the simplest, but producing advanced GUIs can take a very long time. Microsoft Foundation Class is a way to make the Windows API more user friendly and OOP. Does anyone have any experience with MFC?

Aykhan Hagverdili
  • 28,141
  • 6
  • 41
  • 93
phazer
  • 89
  • 7
-1

Why not use some 2D C++ game engine, like HGE: http://hge.relishgames.com/overview.html.

Yuan
  • 1,147
  • 11
  • 16
  • I like the backwards compatibility here. Thanks for your suggestion. I guess I was on the right track thinking I'd need a 2D game engine. – Robbert Feb 14 '14 at 13:29