14

Do you know of a good means of learning C++ win32 (not .Net/MFC/ATL/Wx/Qt..) GUI programming ? A book, a tutorial, an existing project, preferably a hands-on approach with realistic example.. I'm not a beginner, so I don't mind "advanced" starting points..

With thanks.

4
  • So far, its unanimous! Talk about getting a clear direct answer to a question!
    – dicroce
    Commented Oct 17, 2008 at 15:11
  • yes, well ask anyone old enough to remember. The last revision was in 1998.
    – gbjbaanb
    Commented Oct 17, 2008 at 15:14
  • I'm puzzled as to why everyone's recommending "Programming Windows". It doesn't even contain any C++!
    – ilitirit
    Commented Oct 17, 2008 at 15:30
  • It's the API you're trying to learn. That book is the best for it. The C it uses is a complete subset of C++.
    – KTC
    Commented Oct 17, 2008 at 23:06

13 Answers 13

25

Charles Petzolds book is the best.

Programming Windows

3
  • 1
    "Programming Windows" does NOT contain C++ examples. It's a strictly C/Win32 guidebook.
    – ilitirit
    Commented Oct 17, 2008 at 15:31
  • 1
    If you can learn to do it in C, and you know C++, the jump is really trivial.
    – Eclipse
    Commented Oct 17, 2008 at 16:46
  • It is C - but that's what the Win32 SDK basically is, a C-style API. Anything with C++ starts to become a "framework" (junk over the raw API) - which OP says he doesn't want. Worth pointing out, however...
    – Aardvark
    Commented Oct 17, 2008 at 19:47
12

There is no such thing as "C++ Win32 GUI programming". C++ is used for many wrapper libraries that you see around (QT and MFC come to mind). However, pure Win32 programming is entirely procedural in technique, if not in concept. It started out in Pascal, then got recast in C, and it has not gone anywhere since.

3
  • 2
    TITCR. The OP's question is nonsensical, you cannot program win32 in C++ because win32 is a C API.
    – Roel
    Commented Oct 17, 2008 at 16:58
  • 1
    This is so wrong. Win32 is very object-oriented and event-driven, not procedural. There's subtyping everywhere, polymorhpism, code reuse, you name it. (And I'm not just talking about APIs implemented using COM, although there are many of those)
    – Ben Voigt
    Commented Mar 5, 2011 at 4:47
  • 1
    That's what I meant by "if not in concept".
    – user3458
    Commented Mar 8, 2011 at 13:55
7

theForger's Win32 API Programming Tutorial describes itself as "attempts to get you started developing with the Win32 API as quickly and clearly as possible" and that it's projects and solutions are written for Visual C++. It's also available there as a PDF which is only 108 pages long.

4

The Bible of all Win32 programming (including, but not restricted to GUI topics) is Petzold's book.

Make sure you get version 4 or above as previous versions are 16-bit!

2
  • So the versions prior to 3 do not cover win32?
    – Adam Davis
    Commented Oct 17, 2008 at 15:11
  • ahem, that's version 4 or above. No, previous to that there was no Win32. See my edited answer.
    – gbjbaanb
    Commented Oct 17, 2008 at 15:12
4

The #Efnet WinProg channel has a decent tutorial and FAQ. It's not a strictly C++ guide though.

http://www.winprog.org/tutorial/

4

Petzold's programming windows if you can find a copy. All the win32 gui stuff is still there underneath MFc/Winforms etc. http://www.charlespetzold.com/pw5/index.html

edit - as somebody mentioned, the win32 api is purely 'C' as are all the examples in Petzold. This doesn't really matter if you are calling them from C++ except that you will have to understand regular C strings.

3

I guess I learned it the hard way -- entirely through studying VC6's help files. :-) I find VC8's files far less helpful for Win32 programming in general though, because they're riddled with MFC, COM, WinCE, and other things that you can't always filter out.

(I know this answer isn't all that helpful, I'm just saying how I learned.)

3

I got my Win32 experience from Forger's winprog tutorials. It took me almost a year to master that, and let me tell you, I wasn't a C programmer at that time, but now I am. Also, whilst going though them, buy a copy of ANSI C programming by Ritchie and Kernighan II edition.

Use Visual C Express for a start. I write my Win32/C programs using Windows SDK terminal now.

2

You might also want to take a look at the WTL source code.

2

Here is a list of some online Win32 tutorials and here is a list of links to WIN32 SDK help files.

I personally like the Borland Win32 SDK in Winhelp format (from the link above) as it covers all the basics of Win32 and is easier to search than something like the MSDN.

The MSDN is great once you know what your're doing but I suspect it can be quite confusing to new comers.

2

why C++ why not just straight C and WIN32? Its so much easier... Petzold is your answer.

1

I've learned a lot about win32 GUI from Iczelion tutorials. They are basically for win32 assembly, so the source code samples are in MASM not C++, but yet the mechanicks of windows GUI described pretty well. And the API itself doesn't depend on the language anyway.

1
  • Petzold

  • MSDN

  • Advanced Win32 api newsgroup comp.os.ms-windows.programmer.win32 (undocumented apis and any Win32 api source code)