Showing tag results for Code

May 12, 2014
Post comments count0
Post likes count0

Enumerating bit sequences with isolated zero-bits via the Fibonacci recurrence

Raymond Chen
Raymond Chen

Today's Little Program enumerates bit sequences of a particular length subject to the constraint that you cannot have consecutive 0-bits. This may sound kind of arbitrary, but it is important in magnetic media storage, because you cannot go too long without a flux reversal (traditionally represented by a 1); otherwise, the read head's clock start...

Code
May 8, 2014
Post comments count0
Post likes count0

How can you use both versions 5 and 6 of the common controls within the same module?

Raymond Chen
Raymond Chen

Commenter Medinoc was baffled by the statement that the decision to use the visual-styles-enabled version of the common controls library is done on a window-by-window basis. " Isn't it rather on a per-module basis, depending on each module's manifest? If it is indeed on a per-window basis, how does one choose?" Whether a particular call to (or ...

Code
May 7, 2014
Post comments count0
Post likes count0

Why does saving a file in Notepad fire multiple FindFirstChangeNotification events?

Raymond Chen
Raymond Chen

Many people have noticed that the and functions (and therefore their BCL equivalent and WinRT equivalent ) fire multiple events when you save a file in Notepad. Why is that? Because multiple things were modified. Notepad opens the file for writing, writes the new data, calls to truncate any excess data (in case the new file is shorter than t...

Code
May 5, 2014
Post comments count0
Post likes count0

Getting the location of the Close button in the title bar

Raymond Chen
Raymond Chen

Today's Little Program locates the × button in the corner of the window and, just to show that it found it, displays a balloon tip pointing at it. Let's start with the program from last week, the one that displays a balloon tip, then make these changes: Instead of positioning the balloon at the cursor position, we put it at the center ...

Code
May 1, 2014
Post comments count0
Post likes count0

How do I extract an icon at a nonstandard size if IExtractIcon::Extract tells me to go jump in a lake?

Raymond Chen
Raymond Chen

Commenter Ivo notes that if you ask to extract an icon at a particular size, the function can return which means "Go jump in a lake do it yourself." But how can you do it yourself? The and functions don't let you specify a custom size, and doesn't work with icon indices (only resource IDs). The function comes to the rescue. This takes all...

Code
Apr 28, 2014
Post comments count0
Post likes count0

Showing a balloon tip at a specific position, then removing it

Raymond Chen
Raymond Chen

Today's Little Program shows a balloon tip at a specific position, then manually removes it. Start with our scratch program and make these changes: When our main window is created, we also create a balloon-style tooltip and add a tracking tool. Normally, the tooltip control appears and disappears automatically, at a position of the tooltip's ...

Code
Apr 24, 2014
Post comments count0
Post likes count0

I thought you could use SWP_FRAMECHANGED to force a control to recalculate its properties after a change in styles

Raymond Chen
Raymond Chen

Simon Cooke dug back into his memory and asked, "Doesn't calling with cause a recreate and re-apply of the styles?" The flag does not recreate anything, but it does reapply the styles, as far as it knows. Recall that the bits in the window style break into two parts. There are the styles managed by the window manager, which are in the upper ...

Code
Apr 23, 2014
Post comments count0
Post likes count0

How do I programmatically create folders like My Pictures if they were manually deleted?

Raymond Chen
Raymond Chen

A corporate customer had a problem with their employees accidentally deleting folders like Videos and Pictures and are looking for a way to restore them, short of blowing away the entire user profile and starting over. They found some techniques on the Internet but they don't always work consistently or completely. What is the recommended way of r...

Code
Apr 21, 2014
Post comments count0
Post likes count0

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 count0

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