VC++ Programming UESTC Chapter 6 The Modal Dialog and windows common Controls What does modal dialog means? How to use control palette to add controls to your dialog window? Understand the domodal and dodata Exchange e How to add dialog control at runtime? o What are the windows common control and how to program with them
VC++ Programming @ UESTC 1 Chapter 6 The Modal Dialog and Windows Common Controls ⚫ What does modal dialog means? ⚫ How to use control palette to add controls to your dialog window? ⚫ Understand the DoModal() and DoDataExchange() ⚫ How to add dialog control at runtime? ⚫ What are the windows common control and how to program with them
VC++ Programming UESTC Chapter 6 The Modal Dialog and windows common Controls e Almost every Windows-based program uses a dialog to interact with the user e There re two kinds of dialogs: Modal and modeless With a modal dialog, the user cannot work elsewhere in the same application( more correctly the same user interface thread) until the dialog is closed o With modeless dialog, the user can work in another window while the dialog is on the screen
VC++ Programming @ UESTC 2 ⚫ Almost every Windows-based program uses a dialog to interact with the user. ⚫ There’re two kinds of dialogs: Modal and Modeless. ⚫ With a modal dialog, the user cannot work elsewhere in the same application (more correctly the same user interface thread) until the dialog is closed. ⚫ With modeless dialog, the user can work in another window while the dialog is on the screen. Chapter 6 The Modal Dialog and Windows Common Controls
VC++ Programming@UESTC Chapter 6 The Modal Dialog and windows common Controls o a dialog window almost al ways tied to a windows resource that identifies the dialogs elements and specifies their ayout The elements on the dialog are called dialog controls, which include edit control. buttons. list boxes. combo boxes labels tree views, progress indicators, sliders and so forth Windows manages these controls using special grouping and tabbing logic The dialog controls can be referenced by the C Wnd pointer or by an index number 3
VC++ Programming @ UESTC 3 ⚫ A dialog window almost always tied to a Windows resource that identifies the dialog’s elements and specifies their layout. ⚫ The elements on the dialog are called dialog controls, which include edit control, buttons, list boxes, combo boxes, labels, tree views, progress indicators, sliders and so forth. ⚫ Windows manages these controls using special grouping and tabbing logic. ⚫ The dialog controls can be referenced by the CWnd pointer or by an index number. Chapter 6 The Modal Dialog and Windows Common Controls
VC++ Programming UESTC Chapter 6 The Modal Dialog and windows common Controls Steps to add a modal dialog to an existing porject 1.Use the dialog editor to create a dialog resource that contains various control Use Class Wizard to create a dialog class that is derived from Cdialog and attached to the resource created in stepl 3. Use Class Wizard to add data member, exchange functions and validation functions to the dialog class 4. Use Class Wizard to add message handler
VC++ Programming @ UESTC 4 ⚫ Steps to add a modal dialog to an existing porject: 1. Use the dialog editor to create a dialog resource that contains various controls. 2. Use ClassWizard to create a dialog class that is derived from Cdialog and attached to the resource created in step1. 3. Use ClassWizard to add data member, exchange functions and validation functions to the dialog class. 4. Use ClassWizard to add message handler. Chapter 6 The Modal Dialog and Windows Common Controls
VC++ Programming UESTC Chapter 6 The Modal Dialog and windows common Controls
VC++ Programming @ UESTC 5 Chapter 6 The Modal Dialog and Windows Common Controls
VC++ Programming UESTC Chapter 6 The Modal Dialog and windows common Controls 5. Write codes for special control initialization (in OnInitDialog) and for the message handler. Check the OnoK function 6. Write codes in your view class to activate the dialog. Call constructor first, then call DoModal dialog member function
VC++ Programming @ UESTC 6 5. Write codes for special control initialization (in OnInitDialog) and for the message handler. Check the OnOK function. 6. Write codes in your view class to activate the dialog. Call constructor first, then call DoModal() dialog member function. Chapter 6 The Modal Dialog and Windows Common Controls
VC++ Programming UESTC Chapter 6 The Modal Dial and windows common Controls EXO6A visited Use property page to setup parameters for different controls General i Style xtended st ID: IDC_CAT Caption: Hourly v Visible V Group 厂 Help ID V Tab st
VC++ Programming @ UESTC 7 Ex06A visited. Use property page to setup parameters for different controls. Chapter 6 The Modal Dialog and Windows Common Controls
VC++ Programming@UESTC Chapter 6 The Modal Dialog and windows common Controls The Group control serves only to group two radio buttons the style tab and the hourly button has the group proper Be sure that both radio buttons have the auto property set set adio Button Properti H? General Styles Extended Styles I ID: IDC_RADIO2 Caption: Salary v Visible Group 厂Help|D 厂 Disabled M Tab stop
VC++ Programming @ UESTC 8 The Group control serves only to group two radio buttons. Be sure that both radio buttons have the auto property set on the style tab and the Hourly button has the Group property set. Chapter 6 The Modal Dialog and Windows Common Controls
VC++ Programming UESTC Chapter 6 The Modal Dialog and windows common Controls Control palette If it is not visible, right click anytoolbar and choose controls from the list Setting the tabbing order on the dialog 1. click the dialog and you'l see a layout menu occur 2. Choose Tab Order Use the mouse to set the right order Holding down the alt key and pressing the underlined letter on the label, enables the user to jump to the next control in tabbing order
VC++ Programming @ UESTC 9 Control palette If it is not visible, right click anytoolbar and choose controls from the list. Setting the tabbing order on the dialog 1. click the dialog and you’ll see a layout menu occur; 2. Choose Tab Order; 3. Use the mouse to set the right order; 4. Holding down the Alt key and pressing the underlined letter on the label , enables the user to jump to the next control in tabbing order. Chapter 6 The Modal Dialog and Windows Common Controls
VC++ Programming UESTC Chapter 6 The Modal Dialog and windows common Controls Combo box Simple: User can see all choices 2. Drop-down: User can type in any word and choose from the drop-down list 3. Drop List: Use can only select from the attached list Box 4.Use“Ctrl- Enter” to add new line on the“Data?tab section for three types of combo box +i General Data Styles I Extended Styles I listbox French ns: Spanish 0
VC++ Programming @ UESTC 10 Combo box 1. Simple: User can see all choices. 2. Drop-down: User can type in any word and choose from the drop-down list. 3. Drop List: Use can only select from the attached List Box 4. Use “Ctrl-Enter” to add new line on the “Data” tab section for three types of combo box. Chapter 6 The Modal Dialog and Windows Common Controls