views:

117

answers:

6

Hello, so i read a tutorial saying it is not worth it to memorize the windows API template. Do you as programmers memorize the template or just create one from the wizard? also does anyone know a good web source to learn windows programming better? theForger's is okay but more of a reference guide than a learning source

+2  A: 

IMHO, it's not very hard to remember CreateWindow's params by heart. Also, it's pretty useful to be familiar with the native API of the system you are working with.

Pavel Radzivilovsky
+7  A: 

It is always beneficial to understand how something works before using tools that hide some of that stuff away. There's no harm in using class wizards and templates in the long term, but you'll find debugging problems much easier if you grok what things those wizards and templates did for you and what those things do. This holds true whether if is Win32, .NET, or any other API.

It is especially helpful when programming .NET to have an understanding of the operating system on which it executes and how certain .NET features (such as events) map to the underlying system (e.g Windows messages), as this can really help when debugging some bizarre situations (such as re-entrancy in a .NET ListView control when asking for the item count in a paint message).

That said, it is not imperative that you know these things, just helpful. You certainly shouldn't need to remember the signatures of specific methods - documentation will always help you out there. In general, remember how things work, not how you call them.

Jeff Yates
Excellent point -- remember how it works, not the signature of a specific API method.
Nate Bross
+2  A: 

For me. The only way to memorize an API is to use it a lot. There is simply too much to know in most APIs and they change so frequently to memorize them all.

Back in the old days when the Internet was not omnipresent, all info was retrieved from magazines and books. Now it is just a matter of cut and paste from sample code and extending that. I still used Cut and paste for skeleton code from previous projects.

My advice is to understand the APIs and know where to get information quickly.

Romain Hippeau
+1  A: 

Whether you are using a wizard or not, you should have a general understanding of the code being generated so that you can understand exactly how your program works. Everything is documented on in the online MSDN reference, so if there is something you don't understand about the wizard's code, why not look it up?

Personally, I would stick to using templates as a starting point since there can be a lot of boilerplate code when working with the Windows API. But that's just me...

Justin Ethier
+2  A: 

I don't think memorising it is worth it. That's what help files and the Internet are there for.

If you're keen to learn "naked" Win32 programming without .NET, MFC or ATL (and it is good to understand the building blocks these frameworks are built on) then I'd recommend taking it a piece at a time (starting with the basics of WinMain, WndProc etc.) and build your own class framework to cut down on the boilerplate code you write with each new project.

Stick it all in source control, and as you learn more about the API and make improvements to your framework, all of your projects can benefit.

shambulator
i thought MFC is just a wizard for creating API. like dreamweaver is to HTML. so writing win32 API is considered to be the most blane windows programming?
TimothyTech
MFC (Microsoft Foundation Classes) *is* an API - it's an entire framework of classes and functions you use to write Windows programs. It's built on top of another API, the Win32 API, which is the lowest-level set of functions used to write Windows programs. MFC wraps the tedious or repetitive part of this API in classes, in the same way I suggested you do in my answer. The wizard (which isn't the same thing as MFC) doesn't "create API", it creates a minimal Windows program for you from a template, which contains a `WinMain` and calls to API functions, like `CreateWindow`.
shambulator
It is more correct to say that MFC is a C++ wrapper built over Win32 API. It mimics very closely the syntax of the underling API, so a good knowledge of the Windows API is essential to effectively use MFC. Said that, when I have to build native Windows code, I would never use raw APIs but would always use a Framework: MFC or WTL.
Lorenzo
uderstood but those cost money dont they? because my MSVCE doesnt come with it as it appears and dev c++ was kinda clunky and bare.
TimothyTech
+1  A: 

No one would or should memorize Windows API syntax nowadays, we've got IntelliSense in Visual Studio. What you have to do is to understand the model behind these APIs, the way the Windows system works.

Focus on these topics:

  • Window creation and handling, message queues
  • Graphic and font handling (GDI)
  • Standard controls (editbox, buttons...)
  • Events and user input (mouse, keyboard)
  • Processes and threads
  • File handling and other kind of I/O

The most common way is to read some classic book (Charles Petzold's, Jeffrey Ritcher).

By the way, this applies to any framework built over the Windows API: MFC, ATL, and even .net with Windows Forms.

Lorenzo