Showing results for Code - The Old New Thing

Jun 11, 2010
Post comments count0
Post likes count0

How do I indicate that I want my window to follow right-to-left layout rules?

Raymond Chen
Raymond Chen

There are many ways, depending on how wide a scope you want. If there is one specific window that you want to follow right-to-left layout rules, then you pass the extended window style when you create the window. This extended style is inherited by child windows, so once you set a top-level window to have right-to-left layout, all child windows w...

Code
Jun 4, 2010
Post comments count0
Post likes count3

How do I enable and disable the minimize, maximize, and close buttons in my caption bar?

Raymond Chen
Raymond Chen

A customer was having problems with the small icon that appears in the upper left corner of the caption: In my program, I need to enable and disable the Close button programmatically, since the program sometimes goes into a state where I don't want the user to close it. I do this by removing the style when I want to disable the Close button, an...

Code
Jun 1, 2010
Post comments count0
Post likes count0

Why doesn't the Windows Vista copy progress dialog show the names of the files being copied?, redux

Raymond Chen
Raymond Chen

As expected, everybody concluded that the Windows Vista copy progress dialog made every wrong decision possible. Let's look at some of the suggestions on making it suck less: Why not update the file name every five seconds to the file that is being copied at that time? Sure, you could do that, but the cost of getting the name is part of the prob...

Code
May 28, 2010
Post comments count0
Post likes count0

How do I accept files to be opened via IDropTarget instead of on the command line? – bonus content

Raymond Chen
Raymond Chen

One of my colleagues tipped me off to some additional resources on the subject of using the DropTarget technique for accepting files for execution. First, it turns out that there is an SDK sample that demonstrates the DropTarget technique after all. This sample is fifteen years late according to one commenter who apparently thinks that the Plat...

Code
May 28, 2010
Post comments count0
Post likes count0

Every window with the WS_SYSMENU style has a system menu, but it's not there until it needs to be

Raymond Chen
Raymond Chen

I mentioned last time that there's an optimization in the treatment of the system menu which significantly reduces the number of menus in the system. When a window has the window style, it has a system menu, but until somebody calls on that window, nobody knows what its menu handle is. Until that point, the window manager doesn't actually have ...

Code
May 27, 2010
Post comments count0
Post likes count0

When will the window manager destroy a menu automatically, and when do I need to do it manually?

Raymond Chen
Raymond Chen

Our old friend Norman Diamond wonders when you are supposed to destroy a menu and when you are supposed to let Windows destroy it. The rules for when the window manager implicitly destroys menus are actually not that complicated. Outside of the above situations, you are on your own. Of course, when I write that "you are on your own" I do ...

Code
May 26, 2010
Post comments count0
Post likes count0

How do I find the bounding box for a character in a font?

Raymond Chen
Raymond Chen

A customer had the following question: I'm looking for a way to get the height of text which consists entirely of digits, for example , as these characters do not have any descent or internal leading. I expected functions like to return the character's ascent minus the internal leading, but in fact it returns the ascent plus the descent plus t...

Code
May 21, 2010
Post comments count0
Post likes count0

SHAutoComplete giveth, and SHAutoComplete taketh away

Raymond Chen
Raymond Chen

The function lets you attach autocomplete functionality to an edit control, and there are flags that describe what sources you want the autocomplete to draw from. If you call a second time, the second set of flags replace the original flags. The flags do not accumulate. For example, if you first call , and then you later call , the result is tha...

Code
May 20, 2010
Post comments count0
Post likes count0

We've traced the call and it's coming from inside the house: Operating system names

Raymond Chen
Raymond Chen

As the Windows Server 2003 project wound down, somebody reported a serious bug that went something like this: Subject: Windows Server 2003 still refers to itself as Windows .NET Server Previous versions of Windows report the product name correctly, but Windows Server 2003 still calls itself "Windows .NET Server" instead of Windows Server 2003...

Code
May 3, 2010
Post comments count0
Post likes count0

How do I accept files to be opened via IDropTarget instead of on the command line?

Raymond Chen
Raymond Chen

Commenter Yaron wants to know how to use the new IDropTarget mechanism for receiving a list of files to open. (Also asked by Anthony Wieser as a comment to an article.) The MSDN documentation on Verbs and File Assocations mentions that DDE has been deprecated as a way of launching documents and that you should use the DropTarget method instead....

Code