Showing results for Code - The Old New Thing

Dec 10, 2012
Post comments count0
Post likes count1

Why do some shortcuts not support editing the command line and other properties?

Raymond Chen
Raymond Chen

Ben L observed that some shortcuts do not permit the command line and other options to be edited. "Where is this feature controlled? Is there a way to override this mode?" This question is echoed by "Anonymous (Mosquito buzzing around)" (and don't think we don't know who you are), who in a huge laundry list of questions adds, "Why does the Gam...

Code
Dec 6, 2012
Post comments count0
Post likes count0

Replaying input is not the same as reprocessing it

Raymond Chen
Raymond Chen

Once upon a time, there was an application that received some input and said, "Okay, this input cancels my temporary state. I want to exit my temporary state, but I also want the input that took me out of the temporary state to go to whatever control would have received the input if I hadn't been in the temporary state in the first place." (For exa...

Code
Dec 5, 2012
Post comments count0
Post likes count0

Why do I get notified for changes to HKEY_CLASSES_ROOT when nobody is writing to HKEY_CLASSES_ROOT?

Raymond Chen
Raymond Chen

A customer had a question about the function. We are using it to monitor the tree as follows: If I understand the documentation correctly, this registers for notifications when subkeys are added, deleted, or when values are changed. However, it seems that my event becomes signaled at many other times, for example, when I switch folders in ...

Code
Nov 29, 2012
Post comments count0
Post likes count0

Various ways of performing an operation asynchronously after a delay

Raymond Chen
Raymond Chen

Okay, if you have a UI thread that pumps messages, then the easiest way to perform an operation after a delay is to set a timer. But let's say you don't have a UI thread that you can count on. One method is to burn a thread: Less expensive is to borrow a thread from the thread pool: But both of these methods hold a thread hostage for the d...

Code
Nov 26, 2012
Post comments count0
Post likes count0

How does the window manager decide where to place a newly-created window?

Raymond Chen
Raymond Chen

Amit wonders how Windows chooses where to place a newly-opened window on a multiple-monitor system and gives as an example an application whose monitor choice appears inconsistent. The easy part is if the application specifies where it wants the window to be. In that case, the window is placed at the requested location. How the application choose...

Code
Nov 22, 2012
Post comments count0
Post likes count0

The resource compiler will helpfully add window styles for you, but if you're building a dialog template yourself, you don't get that help

Raymond Chen
Raymond Chen

A customer was having trouble with nested dialogs. They were doing something very similar to a property sheet, with a main frame dialog, and then a collection of child dialogs that take turns appearing inside the frame dialog based on what the user is doing. The customer found that if they created the child dialogs with the function, everything ...

Code
Nov 16, 2012
Post comments count0
Post likes count0

How do I forward an exported function to an ordinal in another DLL?

Raymond Chen
Raymond Chen

The syntax for specifying that requests to import a function from your DLL should be forwarded to another DLL is This says that if somebody tries to call from , they are really calling in . This forwarding is done in the loader. Normally, when a client links to the function , the loader says, "Okay, let me get the address of the function in...

Code
Nov 15, 2012
Post comments count0
Post likes count0

If you're going to write your own allocator, you need to respect the MEMORY_ALLOCATION_ALIGNMENT

Raymond Chen
Raymond Chen

This time, I'm not going to set up a story. I'm just going to go straight to the punch line. A customer overrode the operator in order to add additional instrumentation. Something like this: This worked out okay on 32-bit systems because in 32-bit Windows, is 8, and is also 8. If you start with a value that is a multiple of 8, then add 8 ...

Code
Nov 13, 2012
Post comments count0
Post likes count0

Microsoft Money crashes during import of account transactions or when changing a payee of a downloaded transaction

Raymond Chen
Raymond Chen

Update: An official fix for this issue has been released to Windows Update, although I must say that I think my patch has more style than the official one. You do not need to patch your binary. Just keep your copy of Windows 8 up to date and you'll be fine. For the five remaining Microsoft Money holdouts (meekly raises hand), here's a patch...

Code
Nov 9, 2012
Post comments count0
Post likes count0

Thread affinity of user interface objects: Addendum

Raymond Chen
Raymond Chen

Some time ago, I discussed the thread affinity of device contexts, noting that the and functions must be called from the same thread. The same restriction also applies to printer DCs. Printer DCs must be created and destroyed on the same thread. The printing team imposed this additional rule in order to make it easier for printer driver vendors...

Code