The Old New Thing

The importance of the FORMAT_MESSAGE_IGNORE_INSERTS flag

You can use the message with the flag to indicate that the message number you passed is an error code and that the message should be looked up in the system message table. This is a specific case of the more general case where you are not in control of the message, and when you are not in control of the message, you had better pass the ...

The forgotten common controls: The GetEffectiveClientRect function

The function is another one in the category of functions that everybody tries to pretend doesn't exist. It's not as bad as , but it's still pretty awful. The idea behind the function is that you have a frame window with a bunch of optional gadgets, such as a status bar or toolbar. The important thing is that these optional gadgets all ...

If you want a menu that shows the contents of the My Computer folder, you already know how to do it

Commenter praful asks what to me is a rather confused question, but I'll try to guess what the real question is. If you drag My Computer to the Start button in XP, you get an expanding menu that lets you see all files and folders as submenus. Is this menu available to applications via an API, or do you have to build it yourself? For ...

I don't know what the Lotus internal clipboard formats are either

Apparently some people think my psychic powers extend to being able to steal trade secrets by sheer force of concentration. I've been trying to write an application which allows to drag and drop documents from lotus notes. If I just drag and drop a document from lotus notes to Windows explorer, it creates a .shb file (regular windows ...

You just have to accept that the file system can change

A customer who is writing some sort of code library wants to know how they should implement a function that determines whether a file exists. The usual way of doing this is by calling , but what they've found is that sometimes will report that a file exists, but when they get around to accessing the file, they get the error . The lesser ...

VirtualLock only locks your memory into the working set

When you lock memory with it locks the memory into your process's working set. It doesn't mean that the memory will never be paged out. It just means that the memory won't be paged out as long as there is a thread executing in your process, because a process's working set need be present in memory only when the process is actually executing...

Why do we even have the DefWindowProc function?

Some time ago, I looked at two ways of reimplementing the dialog procedure (method 1, method 2). Commenter "8" wondered why we have a function at all. Couldn't window procedures have followed the dialog box model, where they simply return to indicate that they want default processing to occur? Then there would be no need to ...

Why does GetDiskFreeSpaceEx return the wrong amount of free space?

One customer discovered that viewing the properties of a drive from Explorer shows the amount of disk free space significantly lower than the actual amount of free disk space as resported by the disk management snap-in. The command prompt agrees with Explorer and shows the incorrect result. What's going on? Not surprisingly, both Explorer and...

If you pass enough random numbers, eventually one of them will look valid

One customer traced a problem they were having to the way they were calling a function similar in spirit to this one: This function takes a clipboard format and looks for it on the clipboard. If found, it returns a copy of the data. Looks great, huh? The problem is that the customer would sometimes call the function as . The clipboard...

What's the difference between LVM_HITTEST and LVM_INSERTMARKHITTEST?

One customer was confused by the two list view hit-test messages and . What is the difference between the two? The message tries to find the item the point is over. The message tries to find the item the point is next to. For example, suppose you have two 32×32 items, item zero at (0, 0) and item one at (0, 32). You use...