Showing tag results for Code

Apr 21, 2014
Post comments count0
Post likes count1

How can I get information about the items in the Recycle Bin from script?

Raymond Chen
Raymond Chen

Today we'll do a scripting version of an old C++ program: Printing information about the items in the Recycle Bin. (How you wish to act on the information is up to you.) This is a pattern we've seen a lot. Bind to a folder, enumerate its contents, extract properties. Wow, that was way easier than doing it in C++! Just for fun, I'll do it ...

Code
Apr 17, 2014
Post comments count0
Post likes count1

How can I get the Windows 8 touch keyboard to display autocomplete suggestions like the Bing app?

Raymond Chen
Raymond Chen

A customer observed that if you use the Windows 8 Bing app with the touch keyboard, the top of the touch keyboard includes autocomplete suggestions for quick access. They wanted to know how to enable this in their own application. In the illustration below, it's the two boxes immediately above the keyboard with the words "aol" and "amazon". T...

Code
Apr 14, 2014
Post comments count0
Post likes count1

Enumerating subsets with binomial coefficients

Raymond Chen
Raymond Chen

Inspired by the Little Program which enumerates set partitions, I decided to do the binomial coefficients this week. In other words, today's Little Program generates all subsets of size k from a set of size n. As before, the key is to interpret a recurrence combinatorially. In general, when a recurrence is of the form A + B, it means that at th...

Code
Apr 11, 2014
Post comments count0
Post likes count1

Windows is not a Microsoft Visual C/C++ Run-Time delivery channel

Raymond Chen
Raymond Chen

There's a DLL in the system directory called , and from its name, you might think that it is the Microsoft Visual C/C++ Run-Time library. That is a perfectly reasonable guess. But it would also be wrong. The Microsoft Visual C/C++ Run-Time libraries go by names like or or or , and the debugging versions have a in there, too. And like MFC,...

Code
Apr 10, 2014
Post comments count0
Post likes count1

Why does PrintWindow hate CS_PARENTDC? redux

Raymond Chen
Raymond Chen

Why does hate ? Because everybody hates ! Commenter kero claims that it's "easy to fix" the problem with and . You just remove the style temporarily, then do the normal , then restore the style. The question is then why simply doesn't do this. The question assumes that the described workaround actually works. It may work in limited situati...

Code
Apr 7, 2014
Post comments count0
Post likes count1

Using WM_SETREDRAW to speed up adding a lot of elements to a control

Raymond Chen
Raymond Chen

Today's Little Program shows one way you can implement a better version of . Our first version doesn't use at all. Start with the scratch program and make the following changes: Most of this program was stolen from my scroll bar series. The interesting new bits are that you can add one new item by hitting 1, or you can add ten thousand item...

Code
Apr 4, 2014
Post comments count0
Post likes count1

It's bad enough for a guest to demolish the host's house; demolishing an unrelated person's house is taking it to a whole new level

Raymond Chen
Raymond Chen

"How do I destroy a window that belongs to another process?" The function will not destroy windows that belong to another thread, much less another process. The best you can do is post a message to the window to ask it nicely. The function response to the message by destroying the window, but the window is free to add a custom handler for th...

Code
Mar 31, 2014
Post comments count0
Post likes count1

A puzzle involving dynamic programming, or maybe it doesn't

Raymond Chen
Raymond Chen

Here's a programming challenge: Evaluate the following recurrence relation efficiently for a given array [x0, …, xn−1] and integer k. Hint: Use dynamic programming. In words: If the array has only two elements, then the result is the average of the two elements. If the array has more than two elements, then then t...

Code
Mar 28, 2014
Post comments count0
Post likes count1

The dangers of buffering up posted messages and then reposting them later

Raymond Chen
Raymond Chen

A customer wanted to check that their idea for solving a re-entrancy problem doesn't have any hidden gotchas. We have a window which processes incoming work. One of our work items enters a modal loop, and if new work gets posted to the window while the modal loop is running, our work manager gets re-entered, and Bad Things happen. Our propose...

Code