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

查看:125
本文介绍了在哪里可以开始为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,在这种情况下,请阅读 Petzold MSDN ,其中包含有关Win32的完整参考/指南. 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,那么我假设您热衷于关注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时,最好在编写代码之前尝试对术语有扎实的理解.例如,您需要了解消息泵以及它的工作方式.您需要了解一些概念,例如"所有者绘制的控件"和子类化.当您了解了这些内容(以及更多)后,您会发现使用MFC更容易,因为它在类接口中使用了类似的术语(例如,在了解如何以及何时使用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).

您还可以使用Managed C ++编写.NET GUI应用程序,但是我在一些地方读到,Managed C ++并非真的打算以这种方式使用.而是应将其用作本机/非托管代码与托管代码之间的网关.如果您使用的是.NET,则最好使用VB.NET或C#之类的.NET语言来构建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,则当前可以选择 WPF .我个人认为,鉴于WPF旨在取代WinForms应用程序,您将浪费时间学习构建WinForms应用程序.随着时间的流逝,WPF将会变得更加流行,Winforms最有可能死掉. WPF具有更丰富的API集,并且不受Winforms的许多限制的困扰.但是,如果您选择此路线,则毫无疑问,您必须学习 XAML ,这是驱动WPF应用程序的标记语言.这项技术已经日趋成熟,有很多很棒的地方可以了解它.首先,有一些站点,例如 LearnWPF DrWPF ,其中有一些非常出色的文章.其次,有大量,其中 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.

作为最后的提示...

As a final note...

换句话说,Silverlight.如果您不想走MS路线,可以看看Adobe的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天全站免登陆