哪里是开始为 Windows 编程 GUI 的好地方? [英] Where is a good place to start programming GUIs for windows?

查看:14
本文介绍了哪里是开始为 Windows 编程 GUI 的好地方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用 C 和 C++ 编写控制台和网络客户端/服务器应用程序的经验,但我对使用 win32 可视化 API、MFC、Qt、wxWidgets 等几乎一无所知.从哪里开始,以及什么我应该专注于方法,以便为未来做好准备和稳健?

I have experience writing console and network client/server applications in C and C++, but I know next to nothing about using the win32 visual API, MFC, Qt, wxWidgets, etc. Where is a good place to start, and what method should I specialize in, so as to be future ready and robust?

推荐答案

这是一个相当广泛的问题,因为在 Windows 中编写 GUI 应用程序可以通过多种方式完成.

This is a rather broad question, as programming GUI applications in Windows can be done in so many ways.

开发任何 GUI 应用程序有两个主要部分:语言API/框架.考虑到您有兴趣学习构建 Windows GUI 应用程序,该语言并不是您真正关注的重点.因此,您应该选择一种您已经了解的语言,并使用您选择的语言可以利用的框架或 API.

There are two main parts to developing any GUI app: the language and the API/framework. Considering you're interested in learning to build Windows GUI apps, the language isn't really a point of focus for you. Hence, you should pick a language you already know and work with a framework or API that can be harnessed by your chosen language.

如果你想使用 C,你几乎只能自己处理 Win32 API,在这种情况下阅读 PetzoldRichter 将是很好的起点.Win32 API 可能非常令人生畏,但值得努力学习(恕我直言).网上有很多关于 Win32 的教程,而且总是有 MSDN,有完整的参考/指南Win32 API.确保您不仅涵盖 API,还涵盖其他领域,例如资源/对话框,因为它们是您的 Win32 应用程序的构建块.

If you want to use C you're pretty much restricted to dealing with the Win32 API yourself, in which case reading Petzold or Richter would be great places to start. The Win32 API can be quite daunting, but it's well worth the effort to learn (imho). There are plenty of tutorials on Win32 on the web, and there's always MSDN, with a complete reference/guide to the Win32 API. Make sure you cover not just the API, but other areas such as resources/dialogs as they are building blocks for your Win32 application.

如果您想使用 C++,您拥有使用 C 时的所有选项以及其他一些选项.我建议直接使用 Win32 API,然后转向已知框架,例如 MFC、Qt、wxWindows 或 GTK,这样您就可以花更少的时间处理样板代码,而专注于编写应用程序逻辑.我刚刚列出的最后 3 个选项具有跨平台的额外好处,因此您不必过多担心特定于平台的问题.鉴于你说你想使用 Windows,我假设你热衷于专注于它而不是跨平台——所以使用 MFC,但首先花一些时间使用 Win32 API 来熟悉一些概念.

If you want to use C++ you have all of the options that you have when using C plus a few others. I'd recommend going with the Win32 API directly, and then moving on to a known framework such as MFC, Qt, wxWindows or GTK so that you can spend less time working with boilerplate code and instead focus on writing your application logic. The last 3 options I just listed have the added benefit of being cross-platform, so you don't have to worry too much about platform-specific issues. Given that you said you want to work with Windows, I'll assume you're keen to focus on that rather than cross-platform -- so go with MFC, but spend some time with the Win32 API first to get familiar with some of the concepts.

在处理 MFC 和 Win32 API 时,最好在编写代码之前尝试深入了解术语.例如,您需要了解 消息泵 是什么,以及它是如何工作的.您需要了解owner-drawn 控件"等概念,以及子类化.当您了解了这些(以及更多)内容后,您会发现使用 MFC 会更容易,因为它在其类接口中使用了类似的术语(例如,您需要先了解翻译消息"的含义,然后才能了解如何以及何时使用 PreTranslateMessage).

When dealing with MFC and the Win32 API, it's a good idea to try and get a solid understanding of the terminology prior to writing code. For example, you need to understand what the message pump is, and how it works. You need to know about concepts such as "owner-drawn controls", and subclassing. When you understand these things (and more), you'll find it easier to work with MFC because it uses similar terminology in its class interfaces (eg. you need to know what "translate messages" means before you can understand how and when to use PreTranslateMessage).

您也可以使用托管 C++ 编写 .NET GUI 应用程序,但我在一些地方读到托管 C++ 并不是真正打算以这种方式使用的.相反,它应该用作本机/非托管代码和托管代码之间的网关.如果您使用 .NET,最好使用 .NET 语言(例如 VB.NET 或 C#)来构建您的 GUI.

You could also use Managed C++ to write .NET GUI applications, but I've read in a few places that Managed C++ wasn't really intended to be used in this manner. Instead it should be used as a gateway between native/unmanaged code and managed code. If you're using .NET it's best to use a .NET language such as VB.NET or C# to build your GUIs.

因此,如果您打算使用 .NET,您目前可以选择 WinForms 库,或 WPF.鉴于 WPF 旨在替代它,我个人认为你会浪费时间学习构建 WinForms 应用程序.随着时间的推移,WPF 将变得更加流行,Winforms 很可能会消亡.WPF 具有更丰富的 API 集,并且不受 Winforms 的许多限制.但是,如果您确实选择了这条路线,那么您无疑必须学习 XAML,这是一种驱动 WPF 应用程序的标记语言.这项技术正在成熟,有很多很棒的地方可以了解它.首先,有 LearnWPFDrWPF 有一些非常棒的文章.其次,有 很多 of 质量 书籍rel="noreferrer" rel="nofollow noreferrer">主题.

So if you are going to use .NET, you currently have the choice of the WinForms library, or WPF. I personally feel that you'd be wasting time learning to build WinForms applications given that WPF is designed to replace it. Over time WPF will become more prevelant and Winforms will most likely die off. WPF has a much richer API set, and doesn't suffer from many of the limitations that Winforms does. If you do choose this route, however, you'll no doubt have to learn XAML, which is a markup language that drives WPF applications. This technology is coming of age, and there are many great places to learn about it. First, there are sites such as LearnWPF, and DrWPF which have some really great articles. Secondly, there are plenty of quality books on the topic.

所以,总而言之,一旦你选择了你的语言和技术,这条路实际上很容易.只需拿起一两本书,阅读一些博客,阅读一些代码示例……最重要的是……编写代码.不断写作,不断犯错,并不断从中学习.

So, to sum up, once you've picked your language and tech, the path is actually quite easy. Just pick up a book or two, read some blogs, get into some code samples.. and most importantly ... write code. Keep writing, keep making mistakes, and keep learning from them.

最后一点...

换句话说,Silverlight.如果你不想走 MS 路线,你可以看看 Adob​​e 的 Flash/Flex.Silverlight 和 Flash/Flex 都构建 RIA.我认为这是我们前进的方向.像 Office 这样的应用的日子已经屈指可数了

In other words, Silverlight. If you don't want to go the MS route you might give Adobe's Flash/Flex a look see. Both Silverlight and Flash/Flex build RIA's. Which I think is where we are headed. They days of Office like apps are numbered

我完全不同意.Silverlight 与 WPF 不同.Silverlight 是特定于 Web 的,并且仅具有 WPF 功能的一个子集.鉴于问题要求 Windows GUI 应用程序,Flash/Flex Rich Internet Apps 并不是一个合适的建议.我也不同意富客户端应用程序(例如办公室)的日子已经屈指可数了.

I don't agree at all. Silverlight is not the same as WPF. Silverlight is web-specific, and only has a subset of WPF's features. Given that the question asks for Windows GUI apps, Flash/Flex Rich Internet Apps are not really a fitting suggestion. I also don't agree that the days of Rich Client Applications (such as office) are numbered at all.

我希望这会有所帮助.祝你好运:)

I hope that helps. Good luck :)

这篇关于哪里是开始为 Windows 编程 GUI 的好地方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆