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

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
Mar 9, 2005
Post comments count0
Post likes count0

Using SystemParametersInfo to access user interface settings

Raymond Chen
Raymond Chen

The function gives you access to a whole slew of user interface settings, and it is the only supported method for changing those settings. I'm not going to list every single setting; go read the list yourself. Here are some highlights: Here are some control panel settings. Notice that when using the SPI_SET* commands, you also have to choo...

Code
Mar 7, 2005
Post comments count0
Post likes count0

A timed context menu

Raymond Chen
Raymond Chen

This is sort of in the same spirit as our previous exercise in writing a timed message box, but this is much easier. Here, we use the handy-dandy message to get us out of menu mode. Before displaying the menu, we set a timer. (And we use a thread timer because we don't own the window and therefore don't know what timer IDs are safe to use.)...

Code