如何在 Windows 中开始编程?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5125431/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:06:41  来源:igfitidea点击:

How to start programming in Windows?

windows

提问by ilhan

I've made simple programs in C and C++ with simple compilers (learned it in university; I'm Statistics student). Also I'm amateur PHP programer. Now I want to start programming for Windows.

我用简单的编译器用 C 和 C++ 编写了简单的程序(在大学里学过;我是统计学专业的学生)。我也是业余 PHP 程序员。现在我想开始为 Windows 编程。

  • apps with user interface
  • apps without user interface
  • 带有用户界面的应用程序
  • 没有用户界面的应用程序

My aim is just to see how it is done. And I might make a basic app that interacts with a database which is in a web server.

我的目的只是看看它是如何完成的。我可能会制作一个与 Web 服务器中的数据库交互的基本应用程序。

Where should I start? Windows Visual Studio? .NET? What should I know?

我应该从哪里开始?视窗视觉工作室?。网?我应该知道什么?

回答by David Heffernan

If you actually want to learn the underlying API then you should start off without one of the frameworks.

如果您真的想学习底层 API,那么您应该从没有任何框架的情况下开始。

Learn it the way we did it all those years ago with Charles Petzold's book, Programming Windows. A really good foundation of knowledge of how windows and messages work will serve you well.

通过 Charles Petzold 的《Windows 编程》一书,按照我们多年前学习的方式学习它。了解窗口和消息如何工作的基础知识将为您提供良好的服务。

In the longer term, a good framework, e.g. WinForms, Qt, VCL etc. will increase productivity. But if you start with one of them, then you are in danger of not knowing the difference between sent and queued messages, not knowing the difference between an HWND, an HDCand a HANDLE, and so on.

从长远来看,一个好的框架,例如 WinForms、Qt、VCL 等,将提高生产力。但是,如果您从其中一个开始,那么您就有可能不知道已发送消息和排队消息之间的区别,也不知道 an HWND、 anHDC和 a之间的区别HANDLE等等。

A good framework, is great, but you'll get more out of it if you understand what's underneath it.

一个好的框架很棒,但如果你了解它的底层内容,你会从中得到更多。

回答by gideon

See this question:
C# GUI programming for beginners: Where to start?

请参阅此问题:
C# GUI 初学者编程:从哪里开始?

Especially thisanswer there.

特别是那里的这个答案。

I think you should start with Windows Form, WPF is the new thing for Windows Dev and its getting all the lime light, but I would really not recommend starting off with it.

我认为您应该从 Windows Form 开始,WPF 是 Windows Dev 的新事物并且它获得了所有的关注,但我真的不建议从它开始。

Programming Windows Forms by Charles Petzoldis nice book (Charles is very cool) , windows forms hasn't changed all too much since Visual 2005, you should learn C# 4, the latest language.

Charles Petzold 写的 Programming Windows Forms是一本好书(Charles 很酷),自 Visual 2005 以来,windows 窗体并没有发生太大变化,你应该学习 C# 4,最新的语言。

Visual C# 2010 Step by Stepis a good book to get a gist of the .NET world and all your options (including WPF)

Visual C# 2010 Step by Step是一本了解 .NET 世界的要点和所有选项(包括 WPF)的好书

See these SO questions:

请参阅这些 SO 问题:

Hope that helps.

希望有帮助。

Update

更新



Incase you were thinking of going with C or C++ for windows development, is it not easy. I've done some Win32 API and believe me you'll be writing seriously long/complicated programs for even simple things

如果您正在考虑使用 C 或 C++ 进行 Windows 开发,这并不容易。我已经完成了一些 Win32 API,相信我你会为即使是简单的事情编写非常长/复杂的程序

You have two MS options, you can just use the C or C++ language and call the Win32 API functions.

您有两个 MS 选项,您可以只使用 C 或 C++ 语言并调用 Win32 API 函数。

This book is the Bible for that.

这本书就是圣经。

The other MS option is using MFC, people have some rather strong (bad) views about MFC. I haven't done much of it myself so can't say too much. See : https://stackoverflow.com/questions/557114/stick-with-mfc-or-go-to-net

另一个 MS 选项是使用 MFC,人们对 MFC 有一些相当强烈(坏)的看法。我自己没有做过太多,所以不能说太多。请参阅:https: //stackoverflow.com/questions/557114/stick-with-mfc-or-go-to-net

There are of course tons of non-MS options, which again I wouldn't recommend. See : Native Windows Application Development Options

当然有很多非 MS 选项,我也不推荐。请参阅:本机 Windows 应用程序开发选项

Bottom line, in my opinion, C# is a very well done language, you will get TONs of support here, Visual Studio is one of the best tools around, and you will have fun learning C#/.NET, and the biggest advantage is you can use your C# knowledge to write even Web Apps, Cloud and Mobile apps and lots more.

最重要的是,在我看来,C# 是一门非常出色的语言,您将在这里获得大量支持,Visual Studio 是最好的工具之一,您将在学习 C#/.NET 时获得乐趣,最大的优势是您可以使用您的 C# 知识编写甚至 Web 应用程序、云和移动应用程序等等。

回答by void-pointer

I'm not sure why people don't use cross-platform GUI toolkits more often. I tend to write my GUI in Java, and transfer control over to C++ for the actual program logic. If you know about the MVC architectural pattern, you can use Java to implement the view and controller, and C++ to implement the view. If the program is simple and performance isn't critical, then I often code everything directly in Java. I've listed a few pros of cons of using Java for coding UI instead to other languages below.

我不确定为什么人们不更频繁地使用跨平台 GUI 工具包。我倾向于用 Java 编写我的 GUI,并将控制权转移到 C++ 以实现实际的程序逻辑。如果您了解MVC架构模式,您可以使用Java来实现视图和控制器,使用C++来实现视图。如果程序简单且性能不重要,那么我经常直接用 Java 编写所有代码。我在下面列出了使用 Java 编码 UI 而不是其他语言的一些缺点。

Pros

优点

  • Java already has a large library full of useful utilities, and is a good starting point from which one may learn other languages. There's many well-tested Swing components that are ready to use, and tutorials online that give you good starting points for many common use cases.
  • Check out the JogAmpwebsite, and try out their demos. I prefer using C/C++ to do the rendering and Java only for the user-interface, but if performance is not critical, the JogAmp APIs a lot of flexibility in terms of controlling which subset of OpenGL you would like to use.
  • Java has extensive support for databases and servlets - check out the JDBCAPI.
  • Java is open-source, and does not restrict you to using a particular IDE (or operating system!).
  • Java comes with a builtin documentation generator called Javadoc, and it works really well. In fact, documentation for the JDKis generated using it.
  • Java 已经拥有一个充满有用实用程序的大型库,并且是一个很好的起点,可以从中学习其他语言。有许多经过充分测试的 Swing 组件可供使用,还有在线教程为您提供了许多常见用例的良好起点。
  • 查看JogAmp网站,并尝试他们的演示。我更喜欢使用 C/C++ 来进行渲染,而 Java 仅用于用户界面,但如果性能不重要,那么 JogAmp API 在控制您想要使用的 OpenGL 子集方面具有很大的灵活性。
  • Java 对数据库和 servlet 有广泛的支持——请查看JDBCAPI。
  • Java 是开源的,并不限制您使用特定的 IDE(或操作系统!)。
  • Java 带有一个名为 Javadoc 的内置文档生成器,它运行得非常好。事实上,JDK 的文档是使用它生成的。

Cons

缺点

  • Java is an interpreted language, so performance will typically be worse than that of other compiled languages.
  • Java forces you to frame your entire program logic using objected-oriented principles, even when they aren't a good fit for your particular use case (e.g. simple, one-off experiments). Sometimes your code can end up being much more verbose than it needs to be in order to accomplish a particular task.
  • Java 是一种解释型语言,因此性能通常会比其他编译型语言差。
  • Java 强制您使用面向对象的原则来构建整个程序逻辑,即使它们不适合您的特定用例(例如简单的一次性实验)。有时,您的代码最终可能会比完成特定任务所需的冗长得多。

Edit: There are plenty of resources for beginners, such as this one.

编辑:初学者有很多资源,比如这个

回答by bean5

There are various sample codes available for download. I found them very helpful when I was starting to learn to program for windows phone.

有各种示例代码可供下载。当我开始学习为 Windows Phone 编程时,我发现它们非常有用。

Visual Studio works great for C#. You should probably consider creating an account with microsoft whether via outlook.com if you plan on publishing what you develop.

Visual Studio 非常适合 C#。如果您计划发布您开发的内容,您可能应该考虑通过 Outlook.com 创建一个 microsoft 帐户。

If you want to develop for windows 8, I would advise that you install windows 8 and develop using that.

如果您想为 Windows 8 进行开发,我建议您安装 Windows 8 并使用它进行开发。

回答by Greg Buehler

I'm going to go out on a limb and recommend C# using Visual Studio 2010 C# Express. It keeps you familiar with the C/C++ style your probably familiar with.

我打算大胆尝试并推荐使用Visual Studio 2010 C# Express 的 C#。它让您熟悉您可能熟悉的 C/C++ 风格。

回答by Abdullah Md. Zubair

I think you can start with C#.net and then ASP.net

我认为你可以从 C#.net 开始,然后是 ASP.net