Creating GUIs in Win32 C++

丶灬走出姿态 提交于 2020-01-15 23:46:53

问题


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!


回答1:


If you're ok with adding additional Frameworks, I'd suggest looking at QT: http://qt-project.org/

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.




回答2:


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!




回答3:


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.




回答4:


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




回答5:


Using the windows API is the siimplest, but producing advanced GUIs can take a very long time. Microsoft Foundation Class is way to make the Windows Api more user friendly and OOP. Anyone has any experience with MFC?



来源:https://stackoverflow.com/questions/21780505/creating-guis-in-win32-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!