简体   繁体   English

学习Win32开发GUI应用程序

[英]Learning Win32 to develop GUI Applications

如果您是c ++程序员,您会选择Win32 API或.NET来开发GUI应用程序吗?

I would go with Qt . 我会选择Qt It's a cross-flatform C++ GUI framework. 这是一个跨平台的C ++ GUI框架。

Win32 is an API (Application Programming Interface). Win32是一个API(应用程序编程接口)。 So is .NET. .NET也是如此。 So is POSIX. POSIX也是如此。 The first two have GUI toolkits integrated into the main API, but you can use other toolkits such as Qt (as suggested by Skildrick) or wxWindows instead if you choose. 前两个工具具有集成到主要API中的GUI工具包,但是您可以选择使用其他工具包,例如Qt(由Skildrick建议)或wxWindows。 For *nix, the main API is POSIX and almost all of them use X11 as the low-level graphics layer, then you need some GUI toolkit on top (none is integrated into POSIX). 对于* nix,主要API是POSIX,几乎所有API都使用X11作为低级图形层,因此您需要在顶部放置一些GUI工具包(POSIX中没有集成)。 Depending on the type of displays you want, OpenGL is another very good highly portable GUI toolkit, though it focuses on high-speed vector graphics rather than UI widgets. 根据您想要的显示类型,OpenGL是另一个非常好的高度可移植的GUI工具包,尽管它专注于高速矢量图形而不是UI小部件。

One good reason for using the Win32 API's integrated GUI toolkit is that many of the other parts of the Win32 API use it, eg WSAAsyncSelect and MsgWaitForMultipleObjectsEx are non-GUI functions which are integrated into GUI message processing. 使用Win32 API的集成GUI工具包的一个很好的理由是Win32 API的许多其他部分都使用它,例如WSAAsyncSelect和MsgWaitForMultipleObjectsEx是非GUI功能,已集成到GUI消息处理中。 A good wrapper toolkit will give you enough control to continue using these, but few do since this approach is very different with non-Windows OSes and most alternative toolkits value portability above capability. 一个好的包装器工具包将为您提供足够的控制权以继续使用它们,但是很少有这样做的,因为这种方法对于非Windows操作系统而言是非常不同的,并且大多数替代工具包都认为可移植性高于功能。

Even .NET, which is designed from the ground up to run optimally on Windows, can't use asynchronous procedure calls or waitable timers from a UI thread, since none of the message processing in .NET uses MsgWaitForMultipleObjects. 甚至从头开始设计为在Windows上最佳运行的.NET也不能使用来自UI线程的异步过程调用或可等待的计时器,因为.NET中的任何消息处理都不使用MsgWaitForMultipleObjects。 So you end up forced to use multiple threads and a ton of yucky synchronization code. 因此,您最终不得不使用多个线程和大量麻烦的同步代码。

But stay away from MFC. 但是请远离MFC。 It is basically an academic exercise in implementing exceptions without compiler support, not the kind of framework you want for serious applications. 从根本上讲,这是在没有编译器支持的情况下实现异常的学术活动,而不是您想要用于严重应用程序的框架。 Most of the other "features" got added after modern C++ design was much better understood but continue to use the dangerous messy style started by the early hacks on exceptions and virtual inheritance in the name of keeping things consistent. 在现代C ++设计被更好地理解之后,大多数其他“功能”得到了补充,但是它们继续使用危险的凌乱风格,这种混乱的风格是由早期对异常和虚拟继承的入侵开始的,目的是保持事物的一致性。 There are much better choices available today. 今天有更好的选择。

I'd say do both. 我想都做。 I learned a little Win32 stuff before .NET came out. 在.NET出现之前,我学到了一些Win32知识。 I played around with both the Win32 API itself and MFC. 我玩过Win32 API本身和MFC。 It was very educational. 这是很有教育意义的。 I learned a lot about how Windows treats your application and things it expects you to do. 我学到了很多有关Windows如何对待您的应用程序以及它希望您做的事情的知识。 If I go back and learned .NET now, I'm fairly certain I'd appreciate it more than I would without any prior experience. 如果我现在回过头来学习.NET,我肯定会比没有任何经验的人更喜欢它。

Try this free book - I found it very good. 试试这本免费的书-我发现它很好。 It's a guide to C# and .net for C++ programmers and skips right by the usual kiddy stuff. 这是面向C ++程序员的C#和.net指南,并且跳过了通常的小东西。

http://www.charlespetzold.com/dotnet/ http://www.charlespetzold.com/dotnet/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM