13

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.

  • 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.

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

ilhan
  • 8,700
  • 35
  • 117
  • 201
  • 2
    Do you want to stick with the C or C++ language you already know, or are you willing to learn another language like C#? (It amazes me how all the answers so far just *assume* that you want to use the .NET platform.) There are a ridiculous number of options available; Windows programming is a very broad topic. – Cody Gray - on strike Feb 26 '11 at 06:34
  • @Code Gray true! =P but honestly going the C\C++ route for windows programming is not easy. – gideon Feb 26 '11 at 06:36
  • I'm willing to learn another language if needed, yes I'm willing. – ilhan Feb 26 '11 at 06:41
  • @ilhan a friend of mine just like you coming from an ancient C background, he is really doing well with VC# Step by Step. – gideon Feb 26 '11 at 06:49
  • @giddy: Why isn't it easy? The way I see it, the most difficult part is learning the C or C++ languages! If you know them well (or at least fairly well), the GUI programming is relatively straightforward. – Cody Gray - on strike Feb 26 '11 at 07:11
  • @Code Gray what about the API! Its insanity, it required a deep understanding of how windows works, all the `hwnd`s the obscene `WndProc` with all those nested switch statements, I did always want to give MFC a shot, mostly just to practice C++ (to digress into my own question do you think thats a good idea?) But most of all its the tooling, I mean, intellisense, designers, refactoring... end of the day it helps you write better code if you know what your doing. – gideon Feb 26 '11 at 08:10
  • 2
    @giddy you might find windows and messages hard but if you don't get a good grounding it will hold you back. – David Heffernan Feb 26 '11 at 08:28
  • @David yea I totally agree! Most of my struggles with Win32 came in very handy with Winforms, but I think Win32/C-C++ is good because you know one level of abstraction down, but I'm not sure about how productive it would be to write an LOB app with it in todays day. – gideon Feb 26 '11 at 08:33
  • @giddy: I honestly don't know how you write a "real" app in WinForms without having at least *some* understanding of the Win32 API. I certainly never could. I've since migrated most of my development efforts to raw Win32 or MFC. Some things are more difficult because I don't have all the built-in functionality of the .NET FW at my disposal, but on the other hand, *I spend a whole heck of a lot less time writing P/Invoke definitions*. For a while there, it seemed like that's all I was doing when writing WinForms apps. (And, as should be no surprise, I agree with David Heffernan's comments.) – Cody Gray - on strike Feb 26 '11 at 08:40
  • @giddy: Also, I don't have the seething hatred that everyone else seems to have for MFC. It makes me more productive than straight Win32, while still allowing me to write native apps, so I'm down. Sure there are some oddities, but that's the case with *any* library. The key is *understanding* them, and since it's mostly based on the Win32, I think I do. In that regard, it might be worth learning to make you a better Windows programmer. But as an outlet to learn C++? **Definitely not**. C++ has changed *drastically* since MFC was written. It's no longer a shining example of best practices... – Cody Gray - on strike Feb 26 '11 at 08:43
  • @cody I just know that you'd love Delphi VCL!! – David Heffernan Feb 26 '11 at 08:44

6 Answers6

15

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

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.

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 HDC and a HANDLE, and so on.

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

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Charles Petzold's book has reviews from 2004 saying it is outdated. Is there a more modern alternative? I am sure that reading 1200 pages about 199x windows-programming will teach you many things still applicable today but that does not mean it is an efficient way to learn. – julaine Jun 13 '23 at 08:19
  • @julaine What aspects of Win32 do you think have changed drastically since Petzold's book? – David Heffernan Jun 13 '23 at 09:22
  • I do not know - I speak not as an expert that recommends books he read but as a potential learner of this topic. Judging from the chapter-names in the book I can see that several concept that I would believe to be part of "windows programming" (like directX, COM, .NET) are not listed at all. There is also talk about multiprocessing/threading. In 1998 when the book came out, linux had only processes and no threads, so I would not consider it unlikely that windows had had similar changes and the discussion in the book is incomplete (or at least missing context) – julaine Jun 13 '23 at 12:27
  • @julaine Petzold is still valid for learning the basics of Win32 – David Heffernan Jun 13 '23 at 14:28
10

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

Especially this answer 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.

Programming Windows Forms by Charles Petzold is 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.

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

See these SO questions:

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

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

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

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

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.

Community
  • 1
  • 1
gideon
  • 19,329
  • 11
  • 72
  • 113
5

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.

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 JogAmp website, 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 JDBC API.
  • 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 JDK is generated using it.

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.

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

void-pointer
  • 14,247
  • 11
  • 43
  • 61
  • 5
    The reason people shun something like JAVA for GUI work is that it produces non-native GUI's that look poor and consume obscene amounts of system resources and freeze randomly whilst performing garbage collection. – David Heffernan Feb 26 '11 at 08:00
  • Wow, I was just about to post the same comment as @David, albeit not as carefully worded. +1 – Cody Gray - on strike Feb 26 '11 at 08:06
  • @(Mr. Heffernan): Java can produce native GUIs with the AWT framework. Also, take a look at the Nimbus Look and Feel - many programmers neglect to use it (it takes about three lines of code), so the outdated Metal L&F is used by default: http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/nimbus.html. – void-pointer Feb 26 '11 at 08:13
  • @void do you know some examples of native java GUIs? – David Heffernan Feb 26 '11 at 08:29
  • Sure, any components in java.awt.* serve as bindings over native libraries for each OS: http://en.wikipedia.org/wiki/Abstract_Window_Toolkit. Here is an applet displaying some of them: http://www.krhs.net/computerscience/java/componts.htm. Support for AWT components is admittedly limited; the Swing API offers more resources. Swing components are much more flexible, though: http://jogamp.org/deployment/webstart/jogl-demos/XTrans.jnlp. – void-pointer Feb 26 '11 at 08:41
  • AWT might be an option; I don't know anything about it. But I can tell you just from looking at that screenshot of Nimbus that it's **not** native-looking or feeling. It's like Mac OS X, Gnome, and KDE had a bastard child. And it looks absolutely horrible on Windows. I can't even imagine trying to **use** it. (Because I wouldn't. Another app I wasted time downloading in the first place.) I'm not sure what the big hullaballoo is about skinning or providing "themable" GUIs. The OS already does that. Another benefit is that it's available to *all* apps. Instantly consistent user experience. – Cody Gray - on strike Feb 26 '11 at 09:01
  • Nimbus is part of Swing; AWT is native and separate. You can get AWT components using Java - they'll use the L&F of your OS. Quoted from link: "For Linux and Solaris, the System L&Fs are "GTK+" if GTK+ 2.2 or later is installed, "Motif" otherwise. For Windows, the System L&F is "Windows," which mimics the L&F of the particular Windows OS that is running—classic Windows, XP, or Vista. The GTK+, Motif, and Windows L&Fs are provided by Sun and shipped with the Java SDK and JRE, although they are not part of the Java API." http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html – void-pointer Feb 26 '11 at 09:15
  • @Code Gray And on MacOSX: http://java.sun.com/developer/technicalArticles/JavaLP/JavaToMac2/. – void-pointer Feb 26 '11 at 09:16
  • 1
    @void I'm interested in an example of an app build with Java GUI that looks and feels native. Do you know of one? – David Heffernan Feb 26 '11 at 09:33
  • I believe that Eclipse will automatically use the default L&F of your OS; it's open source and the majority of it is written in Java: http://www.eclipse.org/. – void-pointer Feb 26 '11 at 10:24
  • I thought about Java but it is interpreted language and has very bad performance. – ilhan Feb 26 '11 at 14:02
  • People exaggerate Java's performance; perhaps a decade ago, this was true, but because of Java's garbage collection scheme and JIT, it often beats C++ programs using static allocation in terms of performance. There's a reason why Google uses Java. Either way, I wish you the best luck in learning programming! – void-pointer Feb 27 '11 at 00:41
  • @void: Like David, I'm very curious to see a program written using one of these toolkits that looks native. I visited all the links you posted, but the screenshots look awful. I'm sure some of those things look good in Linux, but I don't use Linux. The OS X stuff is about 10 years out of date; OS X has been out of Public Beta for some time now... Moreover, while I agree that for the majority of business apps, JIT-complied code is *not* a performance bottleneck (I'm a .NET programmer), I don't think it's fair to claim that Java is faster than C++, when you're comparing it to poorly-written C++. – Cody Gray - on strike Feb 27 '11 at 08:54
  • @Code Gray The word count is annoying and I find it difficult to compact what I need to say; please see the edit I made in my original post. – void-pointer Feb 27 '11 at 10:39
2

There are various sample codes available for download. I found them very helpful when I was starting to learn to program for 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.

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

bean5
  • 306
  • 2
  • 9
2

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.

Greg Buehler
  • 3,897
  • 3
  • 32
  • 39
1

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

Abdullah Md. Zubair
  • 3,312
  • 2
  • 30
  • 39