Programming Windows®, Fifth Edition (Developer Reference)

Author: Charles Petzold
This Month Stack Overflow 4


by anonymous   2019-07-21

The generally accepted bible for Win32 is the Petzold book:

It's not online, but worth purchasing if you're serious about Win32, IMHO.

by anonymous   2019-07-21

My first guess, if you're a total GDI/C++ newbie, is that you are probably creating a lot of Pens and Brushes. These are constrained resources in Windows. You can only create so many of them before you start to tax your resources. So either make your Brushes and Pens and Windows, etc all at once and re-use them, or dispose of them properly when you're done. I recommend getting a copy of "the Bible" ( and reading the chapters in there about drawing.

EDIT: It doesn't sound like you're modifying your brushes properly, but since I can't see the code for MakeBrush, I don't know. You're probably creating a lot of brushes behind the scenes and you don't even know it. Seriously, get a copy of Petzold's book and spend an hour or two. You'll end up with more hair on your head later! ;-)

by anonymous   2019-07-21

The classic is Petzold

by anonymous   2019-07-21

Petzolds Programming Windows is probably a good start. It's very extensive.

by anonymous   2018-08-16
It appears to be a mess to you, because you are refusing to do the ground work, and learn about the anatomy of the system you are working with. Read the [WM_PAINT message]( documentation to understand, why your solution exhibits flicker. Better yet, get Petzold's [Programming Windows®]( This is the most efficient way to learn Windows programming.
by anonymous   2018-05-14
This question (and potential answers) are not generally useful. Please take the time to properly abstract the problem you are trying to solve, instead of just asking how to fix your code. Helping you fix your code just means fixing more of your code. If you want to get a handle on programming the Windows API, get Petzold's [Programming Windows®, Fifth Edition](
by anonymous   2018-05-09
[About Painting and Drawing]( explains all of this in exhaustive detail. Although no amount of formal (and informal) documentation can replace a good book. You'll want to get a copy of Petzold's [Programming Windows®, Fifth Edition](
by anonymous   2018-04-02
If you are accessing Windows directly (not using a framework), I recommend [*Programming Windows* by Petzold]( Also search the MSDN database (e.g. "MSDN C++ transfer window text").
by anonymous   2018-03-18
This is explained under the [Device Contexts]( topic. In order to understand that document, you're going to have to get a firm grasp on the Windows API first, specficially [Device Contexts]( If that doesn't help, consider getting a good book, e.g. Petzold's [Programming Windows®](
by anonymous   2018-03-12
@Chaost: In that case you need [Programming Windows®, Fifth Edition](
by anonymous   2018-03-12
Clearly, the [documentation]( suggests, that you do **not** want to use `LR_DEFAULTSIZE`. Besides, learning off of YouTube videos is most certainly not going to be a successful undertaking. Get a [good book]( and take it from there.
by anonymous   2018-03-05
You need Petzold's [Programming Windows®, Fifth Edition]( Guessing won't get you far.
by anonymous   2018-01-14
You can't learn Windows GUI programming by guessing. You need Petzold's [Programming Windows®, Fifth Edition](
by anonymous   2017-12-11
You need [Programming Windows®, Fifth Edition](
by anonymous   2017-11-20
`SRCCOPY` doesn't perform alpha blending. A simple block transfer (which `SRCCOPY` does) is a *lot* faster than alpha blending. Given the code, it's unclear, what you really need. The code (like its formatting) is severely broken. Get a copy of Petzold's [Programming Windows®](
by anonymous   2017-11-20
[WM_COMMAND]( You need a copy of Petzold's [Programming Windows®]( Badly.
by anonymous   2017-11-13
You cannot hope to become proficient at MFC without a *solid* understanding of the Windows API. Start with Petzold's [Programming Windows®](
by anonymous   2017-09-18
There is just so much wrong with the code, it boggles the mind: `1` Don't render in a `WM_LBUTTONDOWN`-handler. Instead, `InvalidateRect` and have the `WM_PAINT`-handler do the rendering. `2` You save the old font, but then just throw it away. You need to select it back into the DC when done. `3` Calling `EndPaint` without `BeginPaint` makes no sense. `4` Inconsistent mixture of generic-text and ANSI strings. `5` No `break;` in a `case` clause. You won't get far by guessing. You need to get a [book](
by anonymous   2017-09-11
[Learn to Program for Windows in C++]( It's also very unlikely that you get anywhere without a good [book]( When done, come back and ask a *specific* question.
by anonymous   2017-09-11
One glaring issue with your code is resource management. You delete objects you do not own, and forget to delete objects you do own. Destroying a device context while you still have objects selected into it you own is a sure recipe for disaster, too. Guessing won't help you solve the issue. Get a [book](, and take it from there.