Showing tag results for Code

Apr 4, 2005
Post comments count0
Post likes count0

The dialog manager, part 5: Converting a non-modal dialog box to modal

Raymond Chen
Raymond Chen

Let's apply what we learned from last time and convert a modeless dialog box into a modal one. As always, start with the scratch program and make the following additions: Not a very exciting program, I grant you that. It just displays a dialog box and returns a value that depends on which button you pressed. The function uses the function t...

Code
Apr 1, 2005
Post comments count0
Post likes count0

The dialog manager, part 4: The dialog loop

Raymond Chen
Raymond Chen

The dialog loop is actually quite simple. At its core, it's just If you want something fancier in your dialog loop, you can take the loop above and tinker with it. But let's start from the beginning. The work happens in DialogBoxIndirectParam. (You should already know by now how to convert all the other DialogBoxXxx functions into DialogBoxInd...

Code
Mar 31, 2005
Post comments count0
Post likes count0

The dialog manager, part 3: Creating the controls

Raymond Chen
Raymond Chen

This is actually a lot less work than creating the frame, believe it or not. For each control in the template, the corresponding child window is created. The control's sizes and position is specified in the template in DLUs, so of course they need to be converted to pixels. The class name and caption also come from the template. There are al...

Code
Mar 30, 2005
Post comments count0
Post likes count0

The dialog manager, part 2: Creating the frame window

Raymond Chen
Raymond Chen

The dialog template describes what the dialog box should look like, so the dialog manager walks the template and follows the instructions therein. It's pretty straightforward; there isn't much room for decision-making. You just do what the template says. For simplicity, I'm going to assume that the dialog template is an extended dialog template....

Code
Mar 29, 2005
Post comments count0
Post likes count0

The dialog manager, part 1: Warm-ups

Raymond Chen
Raymond Chen

I think a lot of confusion about the dialog manager stems from not really understanding how it works. It's really not that bad. I'll start by describing how dialog boxes are created over the next few articles, then move on to the dialog message loop, and wrap up with some topics regarding navigation. There will be nine parts in all. The first maj...

Code
Mar 24, 2005
Post comments count0
Post likes count0

Pointers to virtual functions with adjustors

Raymond Chen
Raymond Chen

As a mental exercise, let's combine two mind-numbing facts about pointers to member functions, namely that all pointers to virtual functions look the same and that pointers to member functions are very strange animals. The result may make your head explode. Consider: Here, the variable consists of a code pointer and an adjustor. The code p...

Code
Mar 23, 2005
Post comments count0
Post likes count0

Why does the debugger show me the wrong virtual function?

Raymond Chen
Raymond Chen

Pointers to virtual functions all look basically the same and therefore, as we learned last time, all end up merged into a single function. Here's a contrived example: If you take a look at and you'll see that the point to the same function: That's because the virtual functions and are both stored in the same location relative to the re...

Code
Mar 22, 2005
Post comments count0
Post likes count1

Why does the debugger show me the wrong function?

Raymond Chen
Raymond Chen

Often you'll be minding your own business debugging some code, and you decide to step into one function and the debugger shows that you're in some other function. How did that happen? You then step through code that does something like this: And when you step into the call to you find yourself in . What happened? What happened is that the...

Code
Mar 17, 2005
Post comments count0
Post likes count0

Your exception handler can encounter an exception

Raymond Chen
Raymond Chen

Consider the following code, written in C# just for kicks; the problem is generic to any environment that supports exception handling. Some time later, you find yourself facing an assertion failure from claiming that you are destroying the document while there are still active plugins. But there is your call to , and it's in a block, and the ...

Code
Mar 10, 2005
Post comments count0
Post likes count1

Why does SystemParametersInfo hang when I pass the SPIF_SENDCHANGE flag?

Raymond Chen
Raymond Chen

If you pass the flag to the function, it will broadcast the message with the wParam equal to the system parameter code you passed. For example, if you call then the system will broadcast the message If there is a window that isn't responding to messages, then this broadcast will hang until that unresponsive window finally resumes respon...

Code