Showing tag results for Code

Jul 27, 2012
Post comments count0
Post likes count1

Psychic debugging: Why your IContextMenu::InvokeCommand never gets called

Raymond Chen
Raymond Chen

A customer reported a problem with their shell context menu extension. I have implemented the shell extension, but when the user selects my custom menu item, my is never called. Can anyone please let me know what the problem could be and how to fix it? Since there really isn't much information provided in this request, I was forced to invoke m...

Code
Jul 25, 2012
Post comments count0
Post likes count1

One way to make sure you pass an array of the correct size

Raymond Chen
Raymond Chen

Another entry in the very sporadic series of "very strange code I've seen." The code has been changed to protect the guilty, but the essence has been preserved.

Code
Jul 19, 2012
Post comments count0
Post likes count1

Why do some font names begin with an at-sign?

Raymond Chen
Raymond Chen

It was a simple question. For some reason, my font selection dialog () shows a bunch of font names beginning with the at-sign (@). These fonts don't work correctly if I use them. Any idea what they are? (I tried searching the Internet, but search engines don't seem to let you search for so it's hard to make much headway.) (And that's why I...

Code
Jul 13, 2012
Post comments count0
Post likes count1

Why doesn't RealGetWindowClass return the real window class for my superclass?

Raymond Chen
Raymond Chen

A customer was reporting that the function was not reporting the base window class of their superclass. (Error checking has been elided for expository purposes.) The customer found that the assertion fails, returning a window class name of "AwesomeWindow" instead of "static". "I thought the point of RealGetWindowClass was to dig through the su...

Code
Jul 12, 2012
Post comments count0
Post likes count1

What happens when you mark a section as DISCARDABLE?

Raymond Chen
Raymond Chen

In the flags you pass to the linker, you can specify that a section be made discardable. What does that mean? If you are a kernel-mode driver, the discardable flag means that the contents will be removed from memory after initialization is complete. This is where you put your initialization code and data. But if you're writing user-mode code, t...

Code
Jul 5, 2012
Post comments count0
Post likes count1

How your taskbar auto-hide settings can keep getting overwritten

Raymond Chen
Raymond Chen

A customer reported that they were observing that some users were finding their taskbar set to auto-hide even though the standard configuration in the company is for the auto-hide feature to be disabled. Going into Taskbar Properties shows Auto-hide the taskbar checked. None of the users had changed their setting to auto-hide manually, so the quest...

Code
Jun 28, 2012
Post comments count0
Post likes count1

You still need the "safe" functions even if you check string lengths ahead of time

Raymond Chen
Raymond Chen

Commenter POKE53280,0 claims, "If one validates parameters before using string functions (which quality programmers should do), the 'safe' functions have no reason to exist." Consider the following function: What could possibly go wrong? You check the length of the string, and if it doesn't fit in the buffer, then you reject it. Therefore, y...

Code
Jun 21, 2012
Post comments count0
Post likes count1

When the default pushbutton is invoked, the invoke goes to the top-level dialog

Raymond Chen
Raymond Chen

One quirk of nested dialogs lies in what happens when the user presses Enter to invoke the default pushbutton: The resulting message goes to the top-level dialog, even if the default pushbutton belongs to a sub-dialog. Why doesn't it send the to the parent of the default pushbutton? I mean, the dialog manager knows the handle of the button, so...

Code
Jun 20, 2012
Post comments count0
Post likes count2

When embedding a dialog inside another, make sure you don't accidentally create duplicate control IDs

Raymond Chen
Raymond Chen

The extended style (known in dialog templates as ) instructs the dialog manager that the dialog's children should be promoted into the dialog's parent. This is easier to explain in pictures than in text. Given the following window hierarchy: The result of the extended style being set is that the children of B are treated as if they were di...

Code
Jun 19, 2012
Post comments count0
Post likes count1

It's not a good idea to give multiple controls on a dialog box the same ID

Raymond Chen
Raymond Chen

When you build a dialog, either from a template or by explicitly calling , one of the pieces of information about each control is a child window identifier. And it's probably in your best interest to make sure two controls on the dialog don't have the same ID number. Of course, one consequence of giving two control the same ID number is that the ...

Code