Presentation is loading. Please wait.

Presentation is loading. Please wait.

© Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline.

Similar presentations


Presentation on theme: "© Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline."— Presentation transcript:

1 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline 13.1 Introduction 13.2 Menus 13.3 LinkLabels 13.4 ListBoxes and CheckedListBoxes 13.4.1 ListBoxes 13.4.2 CheckedListBoxes 13.5 ComboBoxes 13.6 TreeViews 13.7 ListViews 13.8 Tab Control 13.9 Multiple-Document-Interface (MDI) Windows 13.10 Visual Inheritance 13.11 User-Defined Controls

2 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.1 Introduction Continues study of Graphical User Interface Explores: –Menus –LinkLabels –ListBox –CheckedListBox –ComboBoxes –TreeView control –Tab controls –Multiple-document interface windows

3 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.2 Menus Group related commands together Contain: –Commands –Submenus Exit uses Application class to quit Color options mutually exclusive Every option has its own event handler Font style options use XOR operator

4 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.2 Menus Shortcut key Disabled command Separator bar Menu submenu Checked menu item Fig. 13.1Expanded and checked menus.

5 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.2 Menus Text boxes used to add items to menu MainMenu icon Menu Designer Place & character before the letter to be underlined Fig. 13.2Visual Studio.NET Menu Designer.

6 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.2 Menus Fig. 13.3MainMenu and MenuItem properties and events. (1 of 2)

7 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.2 Menus

8 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 1 of 10

9 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 2 of 10

10 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 3 of 10

11 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 4 of 10

12 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 5 of 10

13 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 6 of 10

14 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 7 of 10

15 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 8 of 10

16 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 9 of 10

17 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 10 of 10

18 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.cpp 1 of 1

19 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

20 13.3 LinkLabels Displays links to other objects –Uses event handlers to link to right file or program –Start method of Process class opens other programs Derived from class Label, inherits functionality

21 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.3 LinkLabels LinkLabel on a form Hand image displayed when mouse moves over LinkLabel Fig. 13.6LinkLabel control in running program.

22 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.3 LinkLabels

23 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 1 of 5

24 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 2 of 5

25 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 3 of 5

26 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 4 of 5

27 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 5 of 5

28 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.cpp 1 of 1

29 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

30

31

32 13.4 ListBox es and CheckedList Boxes ListBoxe s –Allow users to view and select from items on a list –Static objects –SelectionMode property determines number of items that can be selected –Property Items returns all objects in list –Property SelectedItem returns current selected item –Property SelectedIndex returns index of selected item –Property GetSelected returns true if property at given index is selected –Use Add method to add to Items collection myListBox-> Items->Add ( “myListItem” )

33 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.4 ListBox es and CheckedList Boxes CheckedListBoxe s –Extends ListBox by placing check boxes next to items –Can select more than one object at one time

34 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.4 ListBox es and CheckedList Boxes Scroll bars appear if necessary Checked item Selected item ListBox CheckedListBox Fig. 13.10ListBox and CheckedListBox on a form.

35 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.4 ListBox es and CheckedList Boxes

36 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.4 ListBox es and CheckedList Boxes Fig. 13.12String Collection Editor.

37 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.4.1 ListBox es Class ListBoxTest –Allows users to add and remove items from ListBox –Uses event handlers to add to, remove from and clear list

38 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 1 of 4

39 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 2 of 4

40 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 3 of 4

41 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 4 of 4

42 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.cpp 1 of 1

43 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

44 13.4.2 CheckedListBox es CheckedListBox derives from class ListBox –Can add to, remove from or clear list –Can select multiple items from the list –Properties CurrentValue and NewValue return state of object selected –Properties CheckedItems and CheckedIndices return the objects and indices of selected items respectively

45 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.4.2 CheckedListBox es

46 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 1 of 3

47 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 2 of 3

48 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 3 of 3

49 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.cpp 1 of 1

50 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

51 13.5 ComboBox es Combine TextBox and drop-down list Add method adds object to collection Properties: –DropDownStyle: determines type of ComboBox –Items: returns objects in the list –SelectedItem : returns object selected –SelectedIndex : returns index of selected item

52 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.5 ComboBox es Click the down arrow to display items in drop- down list Selecting an item from drop-down list changes text in textbox Fig. 13.18ComboBox demonstration.

53 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.5 ComboBox es

54 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 1 of 6

55 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 2 of 6

56 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 3 of 6

57 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 4 of 6

58 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 5 of 6

59 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 6 of 6

60 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.cpp 1 of 1

61 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

62 13.6 TreeViews Displays nodes hierarchically Parent nodes have children The first parent node is called the root Use Add method to add nodes

63 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.6 TreeViews Click + to expand node and display child nodes Root node Click - to collapse node and hide child nodes Child nodes Fig. 13.22TreeView displaying a sample tree.

64 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.6 TreeViews

65 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.6 TreeViews

66 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.6 TreeViews Fig. 13.25TreeNode Editor.

67 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 1 of 4

68 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 2 of 4

69 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 3 of 4

70 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 4 of 4

71 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.cpp 1 of 1

72 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

73 13.7 ListViews Displays list of items –Can select one or more items from list –Displays icons to go along with items

74 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.7 ListViews

75 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.7 ListViews Fig. 13.29Image Collection Editor window for an ImageList component.

76 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 1 of 8

77 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 2 of 8

78 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 3 of 8

79 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 4 of 8

80 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 5 of 8

81 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 6 of 8

82 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 7 of 8

83 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 8 of 8

84 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.cpp 1 of 1

85 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

86 13.8 Tab Control Creates tabbed windows Windows called TabPage objects –TabPages can have controls –Tabpages have own Click event for when tab is clicked

87 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.8 Tab Control Tab pages Fig. 13.32Tabbed pages in Visual Studio.NET.

88 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.8 Tab Control TabPage Controls in TabPage TabControl Fig. 13.33TabControl with TabPages example.

89 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.8 Tab Control Fig. 13.34TabPages added to a TabControl.

90 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.8 Tab Control

91 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 1 of 6

92 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 2 of 6

93 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 3 of 6

94 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 4 of 6

95 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 5 of 6

96 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 6 of 6

97 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.cpp 1 of 1

98 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

99 13.9 Multiple-Document-Interface (MDI) Windows Users can edit multiple documents at once Usually more complex then single-document- interface applications Application window called parent, others child Parent and child menus can be merged –Based on MergeOrder property Child windows can be arranged in parent window: –Tiled windows: completely fill parent, no overlap Either horizontal or vertical –Cascaded windows: overlap, same size, display title bar –ArrangeIcons: arranges icons for minimized windows

100 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.9 Multiple-Document-Interface (MDI) Windows MDI parent MDI child Fig. 13.38MDI parent window and MDI child windows.

101 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.9 Multiple-Document-Interface (MDI) Windows Single Document Interface (SDI)Multiple Document Interface (MDI) Fig. 13.39SDI and MDI forms.

102 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.9 Multiple-Document-Interface (MDI) Windows

103 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.9 Multiple-Document-Interface (MDI) Windows Parent’s icons: minimize, maximize and close Maximized child’s icons: minimize, restore and close Minimized child’s icons: restore, maximize and close Parent’s title bar displays maximized child Fig. 13.41Minimized and maximized child windows.

104 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.9 Multiple-Document-Interface (MDI) Windows Separator bar and child windows 9 or more child windows enables the More Windows... option Child windows list Fig. 13.42MenuItem property MdiList example.

105 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.9 Multiple-Document-Interface (MDI) Windows ArrangeIconsCascade Fig. 13.43MdiLayout enumeration values. (Part 1)

106 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.9 Multiple-Document-Interface (MDI) Windows TileHorizontalTileVertical Fig. 13.43MdiLayout enumeration values. (Part 2)

107 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Child.h 1 of 3

108 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Child.h 2 of 3

109 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Child.h 3 of 3

110 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 1 of 5

111 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 2 of 5

112 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 3 of 5

113 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 4 of 5

114 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 5 of 5

115 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.cpp 1 of 1

116 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

117 13.10 Visual Inheritance Create Form by inheriting from another Form –Derived Form inherits functionality of base Form –Derived Form inherits visual aspects of base Form

118 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline VisualInhritance.h 1 of 3

119 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline VisualInhritance.h 2 of 3

120 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline VisualInhritance.h 3 of 3

121 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

122 13.10 Visual Inheritance inherited components Fig. 13.48Visual Inheritance displayed in the Form Designer.

123 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 1 of 3

124 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 2 of 3

125 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.h 3 of 3

126 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Form1.cpp 1 of 1

127 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved.

128 13.11 User-Defined Controls Custom controls that inherit from other classes –Ex: can change appearance of a label

129 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.11 User-Defined Controls

130 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.11 User-Defined Controls Fig. 13.52Custom-control creation.

131 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.11 User-Defined Controls Fig. 13.53Adding a custom control to the ToolBox.

132 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 13.11 User-Defined Controls New ToolBox iconl Newly inserted control Fig. 13.54Custom control added to the ToolBox and a Form.

133 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline ClockControl.h 1 of 3

134 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline ClockControl.h 2 of 3

135 © Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline ClockControl.h 3 of 3


Download ppt "© Copyright 1992-2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline."

Similar presentations


Ads by Google