Showing tag results for Code

Feb 22, 2010
Post comments count0
Post likes count0

Custom navigation in dialog boxes, redux

Raymond Chen
Raymond Chen

SuperBK asks, "What's the proper way to add keyboard support to a dialog box?" There are many options available to you. The most traditional way is to pick them off in the dialog loop, either hard-coding the keys in code or putting them into resources by moving them to an accelerator resource. Moving them to an accelerator resource is a good ide...

Code
Feb 19, 2010
Post comments count0
Post likes count0

The normal string manipulation functions stop on a null terminator, so be careful when manipulating double-null-terminated strings

Raymond Chen
Raymond Chen

One of the many gotchas of working with double-null-terminated strings is accidentally using functions on them which were designed to operate on single-null-terminated strings. Now, you do need to use those single-null-terminated strings, but you also need to know when they won't do what you want. One of the responses to my psychic detection th...

Code
Feb 18, 2010
Post comments count0
Post likes count0

Don't forget to double-null-terminate those strings you pass to SHFileOperation

Raymond Chen
Raymond Chen

About once every two months for the past six months (I stopped checking further back), somebody reports a problem with the function. Often, they don't include very much information at all. They just say, "I call the function and it doesn't work." Here's an example: I'm hitting a problem with when using it to frob files in the gonzo directory ...

Code
Feb 15, 2010
Post comments count0
Post likes count0

Private classes, superclassing, and global subclassing

Raymond Chen
Raymond Chen

In the suggestion box, A. Skrobov asks why it's impossible to superclass , but the example that follows is not actually superclassing. When I register my own class under this atom, and leave NULL in WNDCLASS.hInstance, Windows fills it in for me. Then I have two distinct classes registered: (0,WC_DIALOG) and (hMyInstance,WC_DIALOG), and DialogB...

Code
Feb 12, 2010
Post comments count0
Post likes count0

How do I get information about the target of a symbolic link?

Raymond Chen
Raymond Chen

Functions like and , when asked to provide information about a symbolic link, returns information about the link itself and not the link destination. If you use the function, you can tell that you have a symbolic link because the file attributes will have the flag set, and the member will contain the special value . Okay, great, so now I know ...

Code
Feb 5, 2010
Post comments count0
Post likes count0

Why doesn't my program receive the WM_DWMSENDICONICTHUMBNAIL message when I ask for an iconic representation?

Raymond Chen
Raymond Chen

A customer was having trouble adding Windows 7 taskbar integration features to their application: I'm trying to use the new Windows 7 taskbar integration features, but am running into a problem. I've made certain that my program has the and [corrected 8am] attributes set, yet I never receive a message in my window procedure. A me...

Code
Feb 1, 2010
Post comments count0
Post likes count0

Why can't I use the linker to delay-load a function from kernel32?

Raymond Chen
Raymond Chen

For some time (I am too lazy to look up when it was introduced), the Visual Studio linker has supported a feature known as delay-loading. But why can't you use this feature to delay-load a function from ? It would be very handy: If you write the program fails to load on versions of Windows which do not support the function because the Win32 ...

Code
Jan 29, 2010
Post comments count0
Post likes count0

How do I suppress full window drag/resize for just one window?

Raymond Chen
Raymond Chen

A customer asked, Is there a way to turn off Full Window Drag on a single window? I have a resizable control that I would like not update itself while resizing. It so happens that I wrote a sample program ages ago to illustrate how to do this. You can find it in the Platform SDK under . The source code is also reproduced in this Knowledge ...

Code
Jan 28, 2010
Post comments count0
Post likes count0

What idiot would hard-code the path to Notepad?

Raymond Chen
Raymond Chen

There seemed to be a great deal of disbelief that anybody would hard-code the path to Notepad. Here's one example and here's another. There's a large class of problems that go like this: I'm running Program X, and when I tell it to view the error log, I get this error message: What is wrong and how do I fix it? Obviously, the file is ...

Code
Jan 26, 2010
Post comments count0
Post likes count0

Microspeak: Zap

Raymond Chen
Raymond Chen

You may hear an old-timer developer use the verb zap. That proposed fix will work. Until everybody gets the fix, they can just zap the assert. The verb to zap means to replace a breakpoint instruction with an appropriate number of NOP instructions (effectively ignoring it). The name comes from the old Windows 2.x kernel debugger. (Actually, ...

CodeMicrospeak