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.

In the next two chapters, I'll explain how you can write your own controls. You'll also be able<br />

to see, as you read those chapters, how the architecture of the control framework and the<br />

window server has been influenced by the requirements of dialogs.<br />

10.2 Some Simple Dialogs<br />

Here's a simple dialog, taken from <strong>Chapter</strong> 13's streams application, in action:<br />

Figure 10.6<br />

This shows the typical elements that comprise a single-page dialog:<br />

� a title<br />

� OK and Cancel buttons<br />

� a vertical list of controls – in this case, two controls, each with a caption.<br />

The basic techniques involved in dialog programming are<br />

� constructing the dialog: this is done using resource files<br />

� initializing each control when the dialog is first displayed<br />

� checking individual controls, and the dialog as a whole, for validity<br />

� getting information from each control, and kicking off some action when OK (or another<br />

button) is pressed.<br />

The good news is that you don't have to perform the complicated processing that could be<br />

required, say, for keyboard handling and character drawing within a text control. That's<br />

already done for you by the text editor control, which we'll study later on.<br />

Here's the code from streams.cpp that launches the Write file dialog. It's a command<br />

handler function, CmdWriteFileL(), called directly from HandleCommandL() in the case<br />

for EStreamsExampleCmdWriteFile:<br />

void CExampleAppUi::CmdWriteFileL()<br />

{<br />

// Use a dialog to get parameters and verify them

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

Saved successfully!

Ooh no, something went wrong!