Programming References for the Win32 Environment?
Pablo asks: "I have
to do some programming in Windows (for school, not by choice). To
say that I know jack-all about Windows programming would be
flattering myself. I never do any programming under *NIX without my
trusty copy of Stevens' 'Advanced Programming in the UNIX Environment'
by my side. I'm wondering if there is an equivalent 'bible' reference
book for Windows programming. Does anyone have any
recommendations?"
MSDN
It's free & it contains what you'll need to know.
Finding info is tricky sometimes; nothing's perfect.
---
Oregon
The bible is "Programming Windows" by Charles Petzold. This has been around since 3.1 and is a very good tutorial. Use MSDN as your reference.
9 95 X/o/qid=1012577986/sr=8-2/ref=sr_aps_b_1_2/202-426 8607-1287006
http://www.amazon.co.uk/exec/obidos/ASIN/157231
Swing is fine if you want your app to look like VB shareware from 1993. If you are going to develop anything non-trivial, you're much better off sticking with MFC despite its learning curve and sometimes less-than-elegant implementation.
/.), I spent much more time trying to get the GUI to draw nicely and look decent than making it work.
Having done only a tiny amount of Swing work (so I'm not the most qualified judge of it in the world, but hey, this is
If cross-platform is your highest criteria, than some implementation of Java is probably your best bet, but otherwise, I'd stick with native code and API's.
You are in a maze of twisty little passages, all alike.
yeah, i can agree that getting a Swing GUI app to look correctly is tricky, but would be just as tricky in other settings like the Perl/Tk API. However, I have found that the more I've worked with Swing, the easier it becomes just out of practice using it and the experience gained out of it.
IMO, saying it looks like VB is stretching it. If it looks like a 93 VB app then someone probably didnt know what they were doing when they coded up the GUI part of the tool. I know for one there's a GNUtellium written in Java that looks like any other Windows app when I run it using the Windows-look-n-feel.
There are IDEs out there for targeting the JVM that include GUI-builders. These may work in getting things to look good, but I've never used them, so i cant say which are good/bad.
The One Rule Of Chess You'll Ever Need: Don't play someone who carries a kit in their bookbag.
As others have said, avoid MFC like the plague - just write Petzold "Programming Windows" style code. As long as you can find all the API's you need (MSDN helps, but often doesn't search well - example code is a lot better), C programming under Windows is pretty easy.
.NET it's probably the best way to go right now. C#, or even VB.NET, are pretty dang easy to use. Might even make for compatible code once Mono is working.
That said, if you have the option of using
Either way, much better than sifting through MFC you'll never use again.
Let's not stir that bag of worms...
Basically COM treats things in a client-server way, so that you can e.g. write a Python client to Excel that will let Excel do all the heavy lifting -- optionally in the background -- and then you get back the results and display them in a GUI or insert into a database or pipe out across the network or what have you. Conversely, you can write a COM server that can have Excel (or whatever, that's just the example I'm using) act as a client, with your Python (or whatever) program doing the work. Moreover, with DCOM (which seems to be the exact same thing but with an amended title), the clients & servers don't have to be on the same machine (as you'd probably expect of anything calling itself client-server). The bridge from this present-day model to the pervasively distributed .NET framework we keep hearing about should be pretty obvious.
When you get into COM, it's much more similar to the Unix "small programs / filters" model than I was expecting, at least in certain abstract ways. Obviously you hear a lot of griping about it, especially here on Slashdot, but COM does seem to be a pretty solid framework for GUI application development, and much better than Motif, GTK, Bonobo, Swing etc, from what little I know about those systems. (I'm not trying to flame or troll, just speaking as a interested observer / non-developer of gui frameworks.)
But again, what are you trying to do exactly? Aside from suggesting digging up some COM (and, presumably, MFC) references, the next question is what problem are you trying to solve, and what tools are you considering using? I've played around with Windows Python, based largely on what I learned about it & COM by reading Python Programming on Win32, and it seems like it isn't too hard (and it's much nicer than Visual Basic for the same tasks). I also read Dave Roth's Win32 Perl Programming: The Standard Extensions and Win32 Perl Scripting: Administrator's Handbook, and the material was good but I'm not convinced that Perl is as good of a fit for the Win32 world -- it's great for short scripts, task automation, sysadmin stuff, etc, but I don't think I'd use it for a user-driven GUI application as I would with Python. (And keep in mind that, in general, I much prefer Perl to Python, and almost always use Perl over Python on other platforms, but I'm trying to match the tool to the role here...).
You might also want to look into Visual Basic & Access -- as a lot of Win32 apps seem to be little more than a VB front end for an Access backend -- as well as VC++, MySQL (works great on Windows, IME), Delphi (never used it but I hear nothing but great things about it), and RealBasic (Mac oriented but can cross-develop to Win32, and again I hear nothing but great things about it).
DO NOT LEAVE IT IS NOT REAL
I send you this file in order to have your advice.
MSDN. It's free, it's updated often.
If you're doing gui work, you need Programming Windows by Charles Petzold. Anyone who tells you otherwise, I would love to hear from.
If you don't mind a slow ass gui that gobbles memory and will leave you crying early in the morning, then get Programming Windows with MFC by Jeffrey Prosise.
If you require operating systems services like threads, processes, jobs/fibers, dlls, Unicode, etc., you need Programming Applications for Microsoft Windows by Jeffrey Richter. No ifs, ands, or buts.
Then (maybe before?) hit codeguru and codeproject.
[o]_O
See Mahogany for a fairly large cross platform project implemented with wxWindows.
* And remember, it's spelled N-e-t-s-c-a-p-e, but it's pronounced "Mozilla."
Only the MFC book is C++, the other two are C. Pablo mentioned 'Advanced Programming in the UNIX Environment', which means he should have no problem at all with C.
[o]_O
- No only was the book expensive, but it didn't include a disk with the source code. You had to write away to CP himself to get that, and it wasn't cheap either.
- In keeping with the design philosophy of Windows, CP has a "complexity is power, power is complexity" philosophy. This is reflected both in his programming style, and in his prose.
- I expended considerable mental energy on the chapter on memory management -- which left me fairly angry when I read the very last paragraph. This explained that the preceding text (unchanged from the previous edition) was only useful if you planned to write real-mode or protected-mode programs. No sane programmer does these things -- that's why 3.0 was the first version anybody took seriously.
In any case this book (or another like it -- somebody must have written something better by now) is only useful if you need to study the whole basic Windows API from first principles. Very few programmers need to do this. Most build on some high-level API, and only descend to the Petzold level when they need to.If you just need to hack out some quick GUI application, you should use an IDE environment that supports this. Some good ones are available free. If your stay in Windowsville is short and involuntary, you might consider a Java IDE, so at least you'll pick up some skills that you can take back to the Unix world. Or if you neeed native code, you might consider Delphi. Strangely enough, Delphi is quite popular amongst low-level Windows API hackers. This does seem strange, given that Delphi uses a dialect of Pascal, and Windows is very C-centric. But a lot of people feel that Delphi's advantages offset this semantic impedence gap.
This poll indicates that some 75% of VC++ developers (poll states around 3 million) are MFC programmers. This would seem to indicate a fair number of MFC projects in existence, at least among the Visual C++ community. Granted, given the TOTAL number of Windows programmers, this number is quite small, as the vast majority are almost certainly Delphi or VB users; so you're correct.
What'dya mean there's no BLINK tag!?
GPL
* And remember, it's spelled N-e-t-s-c-a-p-e, but it's pronounced "Mozilla."
This is true. I forgot that it lacked that... I wonder if Mahogany implemented theirs as part of wx that could be reused in other projects? I vaguely remember hearing about a wx rich text control that was "in development", whatever that means.
* And remember, it's spelled N-e-t-s-c-a-p-e, but it's pronounced "Mozilla."
... Johnson Hart, Win32 System Programming. It makes a lot of comparisons to the comparable Unix facilities for I/O, security, processes, threads, sockets, IPC, and dynamically loaded libraries.
It's old (1997; think Windows 95 and NT 3.51), and there's nothing about graphical user interfaces, or "modern" stuff such as COM. For what it covers, it's a great introduction, seemingly aimed at Unix programmers.
Stupid job ads, weird spam, occasional insight at
I wouldn't have guessed the number would be so high, nor would I have though Delphi would rank so high.
I guess that's the problem with making judgements based on only your own experience.
Have a good day.
.
Let's not stir that bag of worms...
When I was required to do Windows programming five years, my colleagues referred Charles Petzold's Programming Windows to me. It was a wonderful book for beginners to start out with and it is probably the closest the Windows world has to the "Stephens' books".
You may find more information at his site: charlespetzold.com.
If you have "Programming Windows 95", you know how thorough Petzold is. "Programming Windows" is basically the same but with an emphasis on Windows 98 and Windows 2k. That said, whenever you come across something strange, you can just hit MSDN to figure out what went wrong, so I'm gonna go out on a limb and say you're ok.
[o]_O
Native L&F, no. Qt implements its own widgets across all supported platforms.
:)
While Qt does implement its own widgets, it does still have the native look and feel. I think the Mac is the only platform where there is such a thing as true native widgets.
On Windows, the concept of "native widgets" really only applies to the look and feel. After all, there are many products/compilers to make Windows programs, and they are not all based on MFC (for instance, Borland does their own widgets AFAIK). I believe this is because use of MFC requires licensing. This means Qt is nothing strange on Windows.
And X11 has no concept of native widgets or native look either, but we won't get into that
It's interesting to see the suggestions people have here. Most of them either assume you're going to use MS Visual C++, assume you're going to use MS Something, or say "Use Whizz-Bang-Free-Tool, it's GPL'd!". Although there's a certain amount of merit in each case, I note that you didn't specify either what type of programming you needed to do, or what development tool(s) you had available.
You asked specifically about books, so... Petzold's book on the Windows API is invaluable if you're going to be programming in C or C++ (or if you're brave enough to try assembler). Its use is more limited (IMHO) if you're using other languages, though it might still be good to have on the shelf. The only serious MFC books I know about are the Prosise one mentioned by others, and the one by Kruglinski et al. If you're going to learn MFC (lucky you! :-)) then I'd suggest having a good look through both in a bookshop, and buying the one whose style you prefer. Finally, any Windows programmer -- whatever tool(s) they are using -- really needs access to the MSDN if they're going to do anything beyond the basics. There is simply no better source of raw information available. It's not always as well-written or reliable as it might be, but there's still nothing else with the breadth of information it contains. It's also pretty language-neutral as a reference, which is relatively rare in the Windows world.
Since many have also introduced tools into the mix, I'll offer some opinions here as well. Perhaps it will help if you haven't yet decided what to use.
My first piece of advice is to remember that there are alternatives to Microsoft's tools. Borland's C++ Builder is a nicer tool than Microsoft's Visual C++ in many ways, and their VCL library is much better designed than Microsoft's MFC. Borland's Delphi (essentially an OO version of Pascal, designed for Windows development) is also well-regarded by everyone I've met who uses it, though somehow it never managed to gain much mainstream acceptance. You can also get various free/GPL'd/open source tools, but <asbestos suit on> most of them are lower quality than the professionally developed alternatives and/or missing significant features <asbestos suit off>. There are obvious exceptions, e.g., GCC is a remarkably good C++ compiler (though lacking the standard of IDE you get with Visual C++ or C++ Builder). The exceptions are just that, though. This is advice from a professional Windows programmer, who makes his living by using these tools.
If you just have to develop a simple application -- your typical college project but with a requirement for a Windowns front-end -- then I'd suggest going for one of the popular RAD tools, probably Visual Basic, C++ Builder or Delphi. I'm pretty sure you used to be able to get all of these at heavily reduced prices if you were studying, though I don't know if that's still the case; alas, my days as a student are past... All of these RAD tools do a pretty good job of insulating you from the absurd complexities of the Win32 APIs, and let you get on with writing code that actually does something useful. Just pick your language of choice, BASIC, Pascal or C++, and off you go. I wouldn't dream of trying to write a simple Windows app in C today, BTW; there's just no need to go writing all that boilerplate code or messing with low-level APIs if you're doing a project at college.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
They don't charge for the library, just for access to the important things like betas and whatever "secret" information they give you for the $2000 a year they charge for professional access.
As far as the Luna article, WTF makes you think I don't know what I'm doing? I'm sorry, but a front page article titled "What's new in XP" on the Microsoft DEVELOPERS Network constitutes something being released for developers.
Anyways, you probably work for Microsoft, hence the obvious bias. IF you can't find something to complain about, then you just aren't paying attention.
A couple of people here mentioned Petzold. That's where I got my first introduction to programming Windows. Most of his code is written in C (they call it "SDK-style").
For a good C++ reference, take a look at Jeff Prosise's Programming Windows with MFC . It's an absolutely awesome book.
If it ain't broke, it doesn't have enough features yet.