Showing results for December 2011 - The Old New Thing

Dec 30, 2011
0
1

Using the MNS_DRAGDROP style: Menu rearrangement

Raymond Chen
Raymond Chen

In order to do drag-drop rearrangement of menus, you need four things, most of which we already know how to do. Dragging an item out of a menu. Check. Dropping an item into a menu. Check. Connecting the drag with the drop. Rearranging menu items in response to the operation. Let's do step 4 first, just to mix things up. ...

Code
Dec 29, 2011
0
0

Using the MNS_DRAGDROP style: Dropping in

Raymond Chen
Raymond Chen

Last time, we looked at using the style for dragging items out of a menu. Today, we'll look at dropping them in. Take the program from last time and make the following additions. First, let's add a second item to the menu. Yes, I hard-coded another path. This is a demo, not production code. Anyway, it's time to hook up the message: To...

Code
Dec 28, 2011
0
0

Using the MNS_DRAGDROP style: Dragging out

Raymond Chen
Raymond Chen

Windows 2000 introduced the menu style, which permits drag/drop operations in a menu. Nobody uses this style, probably because it's totally undiscoverable by the end-user. But I'll write a sample program anyway. Mind you, I knew nothing about the menu style until I started writing this entry. But I simply read the documentation, which say...

Code
Dec 27, 2011
0
0

Introducing the for-if anti-pattern

Raymond Chen
Raymond Chen

Over the years, I've seen a bunch of coding anti-patterns. I figured maybe I'll share a few. Today, I'll introduce what I'm calling the for-if anti-pattern, also known as "We'll sell you the whole seat, but you'll only need the edge." This is a special case of the for-case anti-pattern, where all but one of the cases is null. This can natural...

Code
Dec 26, 2011
0
0

Celebrating the end of the gluttony season, but the effects linger

Raymond Chen
Raymond Chen

The Washington State Ferry system has reduced the rated carrying capacity of its fleet because people have gotten fatter: The average weight of an adult passenger has been officially revised from 160 pounds to 185 pounds. (That's from 11 stone 6 to 13 stone 3 in the UK, or from 73kg to 84kg for the rest of the world.) This has happened before: In...

Non-Computer
Dec 26, 2011
0
0

Why is the file size reported incorrectly for files that are still being written to?

Raymond Chen
Raymond Chen

The shell team often gets questions like these from customers: Attached please find a sample program which continuously writes data to a file. If you open the folder containing the file in Explorer, you can see that the file size is reported as zero. Even manually refreshing the Explorer window does not update the file size. Even the command sh...

Tips/Support
Dec 23, 2011
0
0

How do I get the full path for the target of a shortcut file?

Raymond Chen
Raymond Chen

A customer was having trouble obtaining information from a shortcut file. "Here is a sample program that tries to print the target of a shortcut file, but it only gets the file name without a directory. How do I get the full path?" Recall that the structure contains only a file name in the member. It doesn't have any path information. The st...

Code
Dec 22, 2011
0
0

How do I determine programmatically whether a particular language is LTR or RTL?

Raymond Chen
Raymond Chen

Given an , how does one determine whether the language lays out left-to-right or right-to-left? One suggestion was simply to hard-code the list of known right-to-left languages, and if the language isn't on the list, then assume that it is left-to-right. This technique is clearly fragile, because Windows adds support for new languages not infrequen...

Code
Dec 21, 2011
0
0

Deftly solving compatibility problems by withholding information

Raymond Chen
Raymond Chen

One of the continuing compatibility problems that plagued Direct3D was the way it reported texture formats. Historically, the way an application checked which texture formats were available was by calling and passing a callback function which is called once for each supported format. The application's callback made some sort of decision based on t...

History