Showing tag results for 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 count1

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
Jun 14, 2012
Post comments count0
Post likes count1

Now that Windows makes it harder for your program to block shutdown, how do you block shutdown?

Raymond Chen
Raymond Chen

Up until Windows XP, applications could intercept the message and tell Windows, "No, don't shut down." If they were polite about it, they would also inform the user which application blocked system shutdown and why. And if they were really polite about it, they would even provide a way for the user to say, "I don't care; shut down anyway." A...

Code
Jun 8, 2012
Post comments count0
Post likes count1

How can I determine the underlying cause of a EXCEPTION_IN_PAGE_ERROR exception?

Raymond Chen
Raymond Chen

A customer was using memory-mapped files and installed an exception handler to log in-page errors in the memory-mapped file region. They wanted to know how they could obtain the real disk error that resulted in the memory manager not being able to page-in the requested data. Finding the answer isn't that hard. A quick search for reveals that ...

Code
Jun 7, 2012
Post comments count0
Post likes count1

Eventually the window manager simply says that enough is enough

Raymond Chen
Raymond Chen

Many window manager operations are recursive, and eventually the window manager will simply say that enough is enough when the recursion goes too deep. We've seen this when you nest windows more than 50 levels deep or nest menus more than 25 levels deep, for example. (Note also that these limits may change in the future, so don't rely on being a...

Code
Jun 4, 2012
Post comments count0
Post likes count1

Why does PrintWindow hate CS_PARENTDC? Because EVERYBODY hates CS_PARENTDC!

Raymond Chen
Raymond Chen

Commenter kero wants to know why the function hates . (And , and .) Because everybody hates ! (And , and .) We saw earlier that these class styles violate widely-held assumptions about how drawing works. I mean, who would have thought that asking for two device contexts would give you the same one back twice? Or that changes to one device cont...

Code
Jun 1, 2012
Post comments count0
Post likes count1

How do I prefetch data into my memory-mapped file?

Raymond Chen
Raymond Chen

A customer created a memory mapping on a large file and found that when the memory manager wanted to page in data from that file, it did so in 32KB chunks. The customer wanted to know if there was a way to increase the chunk size for efficiency. The memory manager decides the chunk size for memory-mapped files, and the chunk size is currently set ...

Code
May 31, 2012
Post comments count0
Post likes count1

What happens if I call KillTimer with a NULL hwnd?

Raymond Chen
Raymond Chen

A customer discovered a bug in their code and wanted some information on how serious it was, so they could assess how urgently they need to issue a fix. We have code that calls with a valid window handle, but then we destroy the window before we get around to calling . When we finally do call , we do so with a window handle. The calls are proba...

Code