Advanced MFC Programming
Supporting Document
ii
Table of Contents
TOOL BAR AND DIALOG BAR
1.1. Adding an Extra Docking Tool Bar
Default Tool Bar
Tool Bar Implementation
Message Mapping
Adding New Tool Bar Resource
Declaring New Member Variable
Creating New Tool Bar
Command Message Mapping
1.2. Imitating the Behavior of Radio Buttons
Radio Button & Check Box
Sample
1.3. Check Box Implementation
Using Boolean Type Variables
Function CButton::SetButtonInfo(…)
1.4. Message Mapping for a Contiguous Range of Command IDs
Contiguous IDs
Modifying an ID
1.5. Fixing the Size of Tool Bar
1.6. Adding Combo Box to Tool Bar
1.7. Modifying the Default Styles of Tool Bar
1.8. Dialog Bar
1.9. Resizable Dialog Bar
Deriving New Class from CDialogBar
Resizing Edit Control
Dynamic Layout
Using the New Class
1.10. Adding Flyby and Tool Tip
1.11. Toggling Control Bars On/Off
Summary:
MENU
2.1 Message WM_COMMAND and UPDATE_COMMAND_UI
Handling WM_COMMAND Command
Enabling & Disabling a Command
Changing Menu Text
iii
Checking a Menu Item
2.2 Right Click Pop Up Menu
Adding Menu Resource
Trapping Right Button Clicking Event
Using Class CMenu
Implementing Right-Click Menu
Message Mapping for Right-Click Menu
2.3 Updating Menu Dynamically
Menu Struture
Inserting and Removing Menu Item
Sample Implementation
2.4 Bitmap Check
2.5 System Menu and Bitmap Menu Item
System Menu
Bitmap Menu Item
New Functions
Menu Modification
Message Mapping for System Command
2.6 Owner-Draw Menu
Overriding Two Functions
Drawing a Bitmap
Deriving a New Class from CMenu
Overriding Function CMenu::MeasureItem(…)
Overriding Function CMenu::DrawItem(…)
Using the New Class
2.7 Changing the Whole Menu Dynamically
Summary
SPLITTER WINDOW
3.1 Implementing Static Splitter Windows
3.2 Dynamic Splitter Window
3.3 Customizing the Behavior of Split Bar
Splitter Window Layout
Overriding CSplitterWnd::DeleteRow(…) and CSplitterWnd:: DeleteColumn(…)
Using the New Class
3.4 Customizing the Default Appearance
Drawing Functions
Sample
3.5 Splitter Window That Can’t be Resized by Tracking
Summary
iv
BUTTONS
4.1 Bitmap Button: Automatic Method
Button States
Owner-Draw Bitmap Button
Automatic Method
Sample
4.2 Bitmap Check Box and Radio Button: Method 1
4.3 Subclass
Implementing Subclass
Bitmap Button
4.4 Bitmap Check Box and Radio Button: Method 2
4.5 Irregular Shape Bitmap Button
Transparent Background
New Class
Overriding Function CBitmapButton::LoadBitmaps(…)
Overriding Function CBitmapButton::AutoLoad(…)
Overriding Function CBitmapButton::DrawItem(…)
Using Class MCBitmapButton
4.6 Making Button Aware of Mouse Position
Trapping Message WM_LBUTTONUP within Button
User-Defined Message
Sample
4.7 Mouse Sensitive Button
Setting Capture
New Class
Implementation
Summary
COMMON CONTROLS
5.1 Spin Control
Using Spin Control with Edit Box
5.2 Customizing the Properties of Spin Control
5.3 Displaying Text Strings in the Buddy Window
5.4 Bitmap Button Buddy
5.5 Slider
Including Slider Control in the Application
Handling Slider Related Messages
5.6 List Box
5.7 Handling List Box Messages
v
Trapping Double Clicking Message
Retrieving the Contents of an Item
Message WM_DESTROY
5.8 Combo Box
Implementing Combo Boxes
Handling Messages CBN_CLOSEUP and CBN_SELCHANGE
5.9 Trapping RETURN key strokes for the Combo Box
Problem & Workaround
Function CWnd::PreTranslateMessage(…)
Accessing the Edit Box of a Combo Box
5.10 Implementing Subclass for the Edit Box of a Combo Box
Designing New Classes
Implementing Subclass
5.11 Owner Draw List Box and Combo Box
Owner-Draw Styles
Preparing Bitmaps
Identifying Item Types
Handling Message WM_MEASUREITEM
Handling Message WM_DRAWITEM
5.12 Tree Control
Image List
Adding Nodes
Sample
5.13 Handling Tree Control Messages
Handling TVN_ITEMEXPANDING to Change a Node’s Associated Image
Handling TVN_ENDLABELEDIT to Enable Label Editing
Using the New Class
5.14 Drag-n-Drop
Handling New Messages
New Member Variables and Functions
Node Copy
TVN_BEGINDRAG
WM_MOUSEMOVE
WM_LBUTTONUP
5.15 List Control
LV_COLUMN and LV_ITEM
Sample
Creating Image Lists
Creating Columns
Creating Sub-items
Changing List Style Dynamically
5.16 Tab Control
Using Tab Control
Handling Tab Control Message
5.17 Animate Control and Progress Control
- 1
- 2
前往页