Programming Windows with MFC - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Programming Windows with MFC

Description:

Scroll bars. CComboBox 'COMBOBOX' Combo boxes. CEdit 'EDIT' Edit controls. CListBox 'LISTBOX' ... Creates a radio button control that, when clicked, checks ... – PowerPoint PPT presentation

Number of Views:58
Avg rating:3.0/5.0
Slides: 22
Provided by: Jos421
Category:

less

Transcript and Presenter's Notes

Title: Programming Windows with MFC


1
Programming Windows with MFC
2
Chapter 7
  • Controls

3
The Classic Controls
Control Type WNDCLASS MFC Class
Buttons "BUTTON" CButton
List boxes "LISTBOX" CListBox
Edit controls "EDIT" CEdit
Combo boxes "COMBOBOX" CComboBox
Scroll bars "SCROLLBAR" CScrollBar
Static controls "STATIC" CStatic
4
The Classic Controls Creating
  • Create
  • A flat look
  • CreateEX
  • A chiseled look

A list box with flat edges and chiseled edges
5
The four types of button controls
6
The buttons window style
Style Description
BS_PUSHBUTTON Creates a standard push button control
BS_DEFPUSHBUTTON Creates a default push button used in dialog boxes to identify the push button that's clicked if Enter is pressed
BS_CHECKBOX Creates a check box control
BS_AUTOCHECKBOX Creates a check box control that checks and unchecks itself when clicked
BS_3STATE Creates a three-state check box control
BS_AUTO3STATE Creates a three-state check box control that cycles through three stateschecked, unchecked, and indeterminatewhen clicked
BS_RADIOBUTTON Creates a radio button control
BS_AUTORADIOBUTTON Creates a radio button control that, when clicked, checks itself and unchecks other radio buttons in the group
BS_GROUPBOX Creates a group box control
7
Alignment of the text
Style Description
BS_LEFTTEXT Moves the text accompanying a radio button or check box control from the button's right (the default) to its left
BS_RIGHTBUTTON Same as BS_LEFTTEXT
BS_LEFT Left justifies the button text in the control rectangle
BS_CENTER Centers the button text in the control rectangle
BS_RIGHT Right justifies the button text in the control rectangle
BS_TOP Positions the button text at the top of the control rectangle
BS_VCENTER Positions the button text in the center of the control rectangle vertically
BS_BOTTOM Positions the button text at the bottom of the control rectangle
BS_MULTILINE Allows text too long to fit on one line to be broken into two or more lines
8
Push Buttions
  • ON_BN_CLICKED(IDC_BUTTON,OnButtonClicked)
  • void CMainWindowOnButtonClicked ()
  • MessageBox (_T ("I've been clicked!"))

9
Check Boxes
  • CButtonSetCheck
  • //Check Check Boxes
  • m_wndCheckBox.SetCheck(BST_CHECKED)
  • //Uncheck Check Boxes
  • m_wndCheckBox.SetCheck(BST_UNCHECKED)

10
The CListBox Class
  • Encapsulates list box controls
  • Display lists of text strings called items
  • ON_LBN message-map macros

11
The CListBox Classes
  • Creating
  • m_wndListBox.Create (WS_CHILD WS_VISIBLE
    LBS_STANDARD, rect, this, IDC_LISTBOX)
  • Adding and Removing Items
  • CListBoxAddString and CListBoxInsertString
  • CListBoxDeleteString
  • CListBoxGetCount

12
List Box Notifications
Notification Sent When Message-Map Macro LBS_NOTIFY Required?
LBN_SETFOCUS The list box gains the input focus. ON_LBN_SETFOCUS No
LBN_KILLFOCUS The list box loses the input focus. ON_LBN_KILLFOCUS No
LBN_ERRSPACE An operation failed because of insufficient memory. ON_LBN_ERRSPACE No
LBN_DBLCLK An item is double-clicked. ON_LBN_DBLCLK Yes
LBN_SELCHANGE The selection changes. ON_LBN_SELCHANGE Yes
LBN_SELCANCEL The selection is canceled. ON_LBN_SELCANCEL Yes
13
CStatic Class
  • Static controls
  • Created from the STATIC WNDCLASS
  • Text, rectangles, and images

14
The FontView Application
15
The CEdit Class
  • Encapsulates the functionality of edit controls
  • Used for text entry and editing
  • Single-line and multi-line

16
A dialog box with two single-line edit controls.
17
Creating an Edit Control
  • CEditCreate
  • CEditSetLimitText

18
Inserting and Retrieving Text
  • CEditSetWindowText
  • CEditGetWindowText
  • CEditReplaceSel
  • CEditGetLine

19
The CComboBox Class
  • Combines a single-line edit control
  • Three varieties
  • Simple
  • Drop-down
  • Drop-down list

20
A combo box with a drop-down list
21
The CScrollBar Class
  • Encapsulates scroll bar controls
  • Created from the "SCROLLBAR" WNDCLASS
  • Adding WS_VSCROLL and WS_HSCROLL flags to the
    window style
  • CScrollBarCreate
Write a Comment
User Comments (0)
About PowerShow.com