Showing tag results for Code

Dec 29, 2011
Post comments count0
Post likes count1

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
Post comments count0
Post likes count1

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
Post comments count0
Post likes count1

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 23, 2011
Post comments count0
Post likes count1

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
Post comments count0
Post likes count1

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 19, 2011
Post comments count0
Post likes count1

Paint messages will come in as fast as you let them

Raymond Chen
Raymond Chen

There is a class of messages which are generated on demand rather than explicitly posted into a message queue. If you call or and the queue is empty, then the window manager will look to see if one of these generated-on-demand messages is due, messages like , , and . Neil wonders, "In that program that called 100,000 times, how many paint messa...

Code
Dec 16, 2011
Post comments count0
Post likes count2

Programmatically controlling which handles are inherited by new processes in Win32

Raymond Chen
Raymond Chen

In unix, file descriptors are inherited by child processes by default. This wasn't so much an active decision as it was a consequence of the fork/exec model. To exclude a file descriptor from being inherited by children, you set the flag on the file descriptor. Win32 sort of works like that, but backwards, and maybe a little upside-down. And i...

Code
Dec 12, 2011
Post comments count0
Post likes count1

What is the API for accessing content on SkyDrive?

Raymond Chen
Raymond Chen

The last time I mentioned programmatic access to SkyDrive was last June, where I noted that the interface was given the confusing name Messenger Connect. At least now they renamed it to Live Connect, which is slightly less confusing. The SkyDrive folks have been pretty busy lately. A few days ago, Dare Obasanjo announced a new Live Connect SDK,...

Code
Dec 12, 2011
Post comments count0
Post likes count1

How can I tell whether a window is modal?

Raymond Chen
Raymond Chen

A customer wanted a way to determine whether a particular window is modal. They listed a few methods they had tried but found that it didn't work and asked for assistance. As Eric Lippert is fond of saying, "First, write your spec." Until you know what you want, you won't know how to get it. First, you need to define what you mean by a modal w...

Code
Dec 9, 2011
Post comments count0
Post likes count1

Sure, I'm supposed to pass WT_EXECUTELONGFUNCTION if my function takes a long time, but how long is long?

Raymond Chen
Raymond Chen

A customer contacted me to tell a story and ask a question. The customer discovered that in their code base, all calls to passed the flag, regardless of whether the function actually took a long time or not. Their program creates a large number of work items at startup, and the result of passing for all of them was that the thread pool created a...

Code