03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 4.4<br />

After NewApplication(), you'll see all the other initialization functions in the application,<br />

document, app UI, and app view classes called in the correct sequence. Eventually, you'll<br />

see CHelloGuiAppView::\Draw() being called, and after that the emulator window is<br />

displayed.<br />

4.8 Command and Event Handling<br />

When you look at the code for HandleCommandL(), you might not think it's worth<br />

debugging – after all, it's just a simple switch statement, and all the case handlers are<br />

one-liners. In fact, it's worthwhile for a number of reasons:<br />

� There are several ways of getting commands to HandleCommandL(), and it's<br />

informative to look at the call stack in the debugger to see how commands that come<br />

from different starting points arrive in the same place.<br />

� Most of the case handlers display an info-message, and when that disappears your<br />

application view has to redraw itself. Because of this, your Draw() function gets called,<br />

with some surprises that we'll return to in <strong>Chapter</strong> 11.<br />

� Most calls to HandleCommandL() are generated as a result of some user-initiated<br />

event (an exception for UIQ is a system-generated Exit command). As we saw in<br />

<strong>Chapter</strong> 2, this means active objects are involved in handling them. We can easily<br />

observe this by debugging through HandleCommandL().<br />

� You begin to get a feel for many of the relationships between the window server,<br />

controls, and your application. These relationships are the stuff of life for GUI<br />

programming, and I'll be explaining them in later chapters.<br />

In the next few sections, we'll invoke commands from the menu and shortcut keys, and I'll<br />

point out some of the interesting things revealed by the debugger.<br />

4.8.1 Pointer-generated Commands from the Menu Bar<br />

Starting with the first of these, use the pointer to select and press a menu option, say Edit |<br />

Item 2.<br />

You'll see the debugger stop at the HandleCommandL() breakpoint, where the Variables<br />

window reveals the value of the aCommand parameter to be 4098, or 0x1002, which is<br />

EHelloGuiCmd2. The Call Stack window reveals what is happening:<br />

CCoeEnv::RunL()

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!