• No se han encontrado resultados

Dos sentencias firmes sobre el mismo hecho y mismo encausado

In document Análisis de los motivos de revisión (página 30-35)

4. LOS MOTIVOS DE REVISIÓN PENAL DEL ART 954 LECrim

4.4. Dos sentencias firmes sobre el mismo hecho y mismo encausado

For the custom dialog that you will add to your application, you will provide the user with a edit box in which to enter some text and a group of radio buttons from which the user can select one. When the user clicks the OK button, your application will display the text entered by the user in the display area of the main application dialog window. There is another button that the user can, can click to display which one of the radio but- tons was selected. This exercise enables you to see how you can use custom dialog win- dows to gather information from the user and how you can read the user’s selections after the dialog window is closed.

To create a custom dialog for your application, you need to • Add another dialog to your application resources. • Design the dialog window layout.

• Declare the base class from which the dialog will be inherited. • Attach variables to the controls on the dialog.

After doing these things, your custom dialog will be ready for your application. To accomplish these tasks, follow these steps:

1. Select the Resource View tab in the project workspace pane.

2. Right-click the Dialogs folder, and select Insert Dialog from the pop-up menu. 3. Right-click the new dialog in the resource tree view, and select Properties from the

pop-up menu.

4. Change the object ID for the new dialog to IDD_MESSAGEDLG.

5. When editing the new dialog window, do not delete the OK and Cancel buttons. Move them to the location shown in Figure 5.6.

6. Design the rest of the window using the object properties in Table 5.7.

TABLE5.7.THE CUSTOM DIALOG CONTROL PROPERTY SETTINGS.

Object Property Setting

Static Text ID IDC_STATIC

Caption Enter a &message:

Edit Box ID IDC_MESSAGE

Multiline Checked Auto Vscroll Checked Group Box ID STATIC

Caption Select an Option

Radio Button ID IDC_OPTION1

Caption &Option 1

Group Checked Radio Button ID IDC_OPTION2

Caption O&ption 2

Radio Button ID IDC_OPTION3

Caption Op&tion 3

Radio Button ID IDC_OPTION4

Caption Opt&ion 4

7. After you design the dialog, open the Class Wizard. You see the dialog in Figure 5.7.

FIGURE5.6.

The custom dialog window layout.

FIGURE5.7.

The Adding a Class dialog.

5

8. Leave the selection on this dialog at the default setting of Create a New Class and click OK. Another dialog appears to allow you to specify the name for the new class and the base class from which it is inherited.

9. Enter the class name CMsgDlginto the Name field, and make sure that the Base

Class is set to CDialog, as shown in Figure 5.8.

FIGURE5.8.

The New Class dialog.

10. Click OK, leaving the other settings on this dialog at their defaults.

11. Once the Class Wizard opens, attach the variables to the controls on the new dialog as specified in Table 5.8.

TABLE5.8.CONTROL VARIABLES.

Object Name Category Type

IDC_MESSAGE m_sMessage Value CString

IDC_OPTION1 m_iOption Value int

You should notice two things in the way that you configured the control properties and variables in the custom dialog. First, you should have selected the Group property on only the first of the radio buttons. This designates that all the radio buttons following that one belong to a single group, where only one of the radio buttons may be selected at a time. If you select the Group property on all the radio buttons, they are all independent of each other, allowing you to select all the buttons simultaneously. This property makes them behave somewhat like check boxes, but the primary difference is that the user would find it difficult to uncheck one of these controls due to the default behavior where one radio button in each group is always checked. The other difference is in their appear- ance; the radio buttons have round selection areas instead of the square areas of check boxes.

The other thing to notice is that you declared a single integer variable for the one radio button with the Group property checked. This variable value is controlled by which radio button is selected. The first radio button causes this variable to have a value of 0, the sec- ond sets this variable to 1, and so on. Likewise, if you want to automatically select a par- ticular radio button, you can set this variable to one less than the sequence number of the radio button in the group of radio buttons.

Because this is the C++ programming language, all numbering begins with 0, not 1. Therefore, the first position in an array or a set of controls is posi- tion 0. The second position is position 1. The third position is number 2, and so on.

Note

You have now finished all that you need to do to the second dialog window to make it ready for use. You would expect to need an UpdateDataor two in the code behind the

dialog, but because you didn’t remove the OK and Cancel buttons from the dialog, the

UpdateDatacall is already performed when the user clicks the OK button. As a result,

you don’t have to touch any code in this second dialog, only in the first dialog.

Using the Dialog in Your Application

Now that your custom dialog is ready for your application, using it is similar to the way that you use the common dialogs that are built into Windows. First, you have to declare an instance of the custom dialog class, which calls the class constructor and creates an instance of the class. Next, you call the dialog’s DoModalmethod and capture the return

value of that function. Finally, you read the values of the variables that you associated with the controls on the dialog.

In document Análisis de los motivos de revisión (página 30-35)

Documento similar