Showing tag results for Code

Aug 4, 2009
Post comments count0
Post likes count1

Programming means that sometimes you have to snap two blocks together

Raymond Chen

Part of the challenge of programming (and for some people, the reason why programming is fun in the first place) is looking at the building blocks provided to you and deciding how to assemble them to build something new. After all, if everything you wanted a program to do already existed ready-made, it wouldn't be called programming any more. It wo...

Code
Jul 31, 2009
Post comments count0
Post likes count1

What is the difference between Directory and DirectoryBackground?

Raymond Chen

One item I left off the list of special progids is . Recall that is the progid for file system folders (a subset of which represents all shell folders, both file system and virtual). Closely related is , which isn't really a progid, but it is a place where shell extensions can register themselves. Specifically, it's where context menu handlers...

Code
Jul 30, 2009
Post comments count0
Post likes count1

What is the difference between CSIDL_DESKTOP and CSIDL_DESKTOPDIRECTORY?

Raymond Chen

Among the various values you can pass to functions like are and . What's the difference between them? The is the virtual folder that represents the desktop. The contents of this virtual folder is what gets displayed on top of your wallpaper. The virtual folder is populated from various locations, some of them virtual, and some of them physic...

Code
Jul 27, 2009
Post comments count0
Post likes count1

Polling by sleeping versus polling by waiting with a timeout

Raymond Chen

Commenter Francois Boucher asks it's better to write a background worker thread that polls with and a flag, or polls by waiting for an event with a timeout? "Which scenario is better? The first one uses only 1 handle for the thread. The second one will use 2. But is the first scenario wasting more thread time? Is it worth using the event (ker...

Code
Jul 24, 2009
Post comments count0
Post likes count1

If you wished a language supported the preprocessor, you know, you can fix that

Raymond Chen

A customer had the following question about the message compiler, something that I had noted almost nobody uses. Well how do you do, we found somebody who actually uses it. Anyway, the question went like this (paraphrased, as always): Can I use symbolic constants in my .mc file? For example, I have a message file that goes like this: I hav...

Code
Jul 17, 2009
Post comments count0
Post likes count0

The disembodiment of DIBs from the DIB section

Raymond Chen

So far this week, we've separated the DIB metadata () from the pixels of a DIB section. But there's really no need for the DIB section at all! As long as you have the pixels and the metadata, you can draw bits. We demonstrate this by drawing a rather stupid-looking bitmap onto the screen, but doing so without the use of s at all! Start with a b...

Code
Jul 16, 2009
Post comments count0
Post likes count0

Caption contest: The pinball machine: Results

Raymond Chen

It's been quite a while, but a winner in the caption contest has been selected and the prize finally reached its destination. (Mostly due to procrastination on my part. Don't blame the postal service.) The winner is Scott from Australia with his entry Only 5,000 more referrals until MULTIBALL Even though it's kind of low-brow, it made me lau...

Code
Jul 16, 2009
Post comments count0
Post likes count0

Separating the metadata from the DIB pixels: Changing the raster operation

Raymond Chen

For a few days now, we've used the function in conjunction with a precomputed to draw a DIB with an alternate color table without modifying the . The function operates like a with raster operation . If you want another raster operation, you can use , which has a final raster operation parameter. Despite its name, you don't have to stretch w...

Code
Jul 15, 2009
Post comments count0
Post likes count0

Separating the metadata from the DIB pixels: Precalculating the BITMAPINFO

Raymond Chen

Last time, we saw that you can use the function to draw a DIB with an alternate color table without having to modify the . In that version of the function, we selected the into a device context in preparation for drawing from it, but in fact that step isn't necessary for drawing. It was merely necessary to get the original color table so we cou...

Code
Jul 14, 2009
Post comments count0
Post likes count0

The fun and profit of manipulating the DIB color table can be done without having to modify it

Raymond Chen

If I were Michael Kaplan, I'd have a more clever title like I'm not touching you! or Look but don't touch or maybe Looking at a DIB through -colored glasses. We saw some time ago that you can manipulate the DIB color table to perform wholesale color remapping. But in fact you can do this even without modifying the DIB color table, which is a h...

Code