Showing results for Code - The Old New Thing

Dec 23, 2010
Post comments count0
Post likes count0

What is the correct way of temporarily changing a thread's preferred UI language?

Raymond Chen
Raymond Chen

A customer ran into a crashing bug in their shell extension. The shell extension wants to change the thread's preferred UI language temporarily, so that it can load its resources from a specific language. You'd think this would be easy: Approximately ten seconds after this code runs, Explorer crashes with the exception whose description is "A ...

Code
Dec 22, 2010
Post comments count0
Post likes count1

The __fortran calling convention isn't the calling convention used by FORTRAN

Raymond Chen
Raymond Chen

Although the Microsoft C compiler supports a calling convention called , that's just what the calling convention is called; its relationship with the FORTRAN programming language is only coincidental. The keyword is now just an old-fashioned synonym for . Various FORTRAN compilers use different calling conventions; the one I describe here appli...

Code
Dec 21, 2010
Post comments count0
Post likes count0

How do I simulate input without SendInput?

Raymond Chen
Raymond Chen

Michal Zygmunt wants to create a system where multiple applications can have focus, with different users generating input and directing them at their target applications. Attempting to simulate this by posting input messages didn't work. "Can you tell us maybe how SendInput is internally implemented so that we can use it to simulate only part of...

Code
Dec 20, 2010
Post comments count0
Post likes count0

Developing the method for taking advantage of the fact that the OVERLAPPED associated with asynchronous I/O is passed by address

Raymond Chen
Raymond Chen

You can take advantage of the fact that the associated with asynchronous I/O is passed by address, but there was some confusion about how this technique could "work" when kernel mode has no idea that you are playing this trick. Whether kernel mode is in on the trick is immaterial since it is not part of the trick. Let's start with a version ...

Code
Dec 17, 2010
Post comments count0
Post likes count1

The OVERLAPPED associated with asynchronous I/O is passed by address, and you can take advantage of that

Raymond Chen
Raymond Chen

When you issue asynchronous I/O, the completion function or the I/O completion port receives, among other things, a pointer to the structure that the I/O was originally issued against. And that is your key to golden riches. If you need to associate information with the I/O operation, there's no obvious place to put it, so some people end up doi...

Code
Dec 16, 2010
Post comments count0
Post likes count0

Why does SHCOLUMNINFO have unusually tight packing?

Raymond Chen
Raymond Chen

Alternate title: News flash: Sometimes things happen by mistake rbirkby asks why the structure has 1-byte packing. "Was the expectation that there would be so many columns in a details view that the saving would be worthwhile?" Hardly anything that clever or ingenious. It's just the consequence of a mistake. When the structure was added t...

Code
Dec 15, 2010
Post comments count0
Post likes count0

There is no interface for preventing your notification icon from being hidden

Raymond Chen
Raymond Chen

Yes, it's another installment of I bet somebody got a really nice bonus for that feature. A customer had this question for the Windows 7 team: Our program creates a notification icon, and we found that on Windows 7 it is hidden. It appears properly on all previous versions of Windows. What is the API to make our icon visible? First of...

Code
Dec 10, 2010
Post comments count0
Post likes count0

How do I limit the size of the preview window used by Aero Snap?

Raymond Chen
Raymond Chen

A customer reported that the translucent preview shows by Aero Snap showed the wrong dimensions for their application window. "As you can see in the screen shot, the preview is too wide. Our application window has a maximum width, but the preview is fully half the width of the screen. How can we disable the Aero Snap feature?" Whoa there, givin...

Code
Dec 9, 2010
Post comments count0
Post likes count0

We've traced the call and it's coming from inside the house: Grid lines in list view report mode

Raymond Chen
Raymond Chen

A customer wanted to know how to remove the grid lines from a list view control in report mode. The customer was kind enough to include the source code for the relevant part of the program and drew our attention to the line in the resource file that he believed to be the source of the problem: The customer didn't know it, but that line in the r...

Code
Dec 6, 2010
Post comments count0
Post likes count0

TrackMouseEvent tracks mouse events in your window, but only if the events belong to your window

Raymond Chen
Raymond Chen

Greg Williams wonders why fails to detect mouse hover events when responding to Do­Drag­Drop callbacks. "My suspicion is that monopolizes the window so that a message is never posted, so it won't end up being useful." That's basically it, for the appropriate sense of the word "monopolize." The monitors mouse events that take place in...

Code