MFC programming with visual c++ 6 unleashed 1999

1.7K 178 0
MFC programming with visual c++ 6 unleashed 1999

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

MFC Programming with Visual C++ 6 Unleashed by David White, Kenn ISBN:0672315572 Scribner, Eugene Olafsen Sams © 1999 (1306 pages) This title demonstrates how to apply MFCs to many common programming problems in addition to techniques such as database creation, networking systems and COM programming, all source code from the book is available enabling the reader to build their own applications Introduction Foreword About the Author Core MFC The MFC Architecture A Brief History of MFC The MFC Class Hierarchy CObject CCmdTarget CWinThread CWinApp CWnd CFrameWnd CView CDocument Summary MFC Dialogs, Controls, and Data Interaction Creating an Application Starting and Using MFC AppWizard The AppWizard-Generated Code Modifying the Application Adding Dialog Controls Adding Initialization Using Dialog Controls ToolTips Enabling ToolTips Displaying Text Dialog Data Exchange Standard DDX UpdateData Using Standard Dialog Boxes File Open/Save Color Selector Font Selector Print Dialog Summary The Windows Common Controls Initializing and Using the Common Controls Notifications for Windows Common Controls The Notification Message Structure Overview of the Notification Process A Better Notification Handling Scheme Specifying Notification Ranges with ON_NOTIFY_RANGE Hot Key Controls: Class CHotKeyCtrl CHotKeyCtrl Class Methods Creating and Initializing a CHotKeyCtrl Object Using a Hot Key Control Spin Controls: Class CSpinButtonCtrl Spin Control Styles CSpinButtonCtrl Messages CSpinButtonCtrl Class Methods Creating and Initializing a Spin Control Sample Program: SPIN1 Slider Controls: Class CSliderCtrl Slider Control Styles CSliderCtrl Messages CSliderCtrl Class Methods Creating and Initializing a Slider Control Sample Program: Slider Controls (SLIDER1) Sample Program: SLIDER1 Progress Bar Controls: Class CProgressCtrl CProgressCtrl Class Methods Creating and Initializing a CProgressCtrl Object Using a Progress Control Image Lists: Class CImageList CImageList Class Methods Creating and Initializing a CImageList Control List View Controls: Class CListCtrl List View Control Styles Image Lists and the List View Control List View Items and Subitems List View Notification Messages Creating and Initializing a CListCtrl Object Using the List View Control Tree View Controls: Class CTreeCtrl Tree View Control Styles Tree View Notification Messages CTreeCtrl Class Methods Creating and Initializing a Tree View Control Using a CTreeCtrl Object Sample Program: TREELIST.EXE Tab Controls: Class CTabCtrl Tab Control Styles Tab Control Notification Messages CTabCtrl Class Methods The Tab Item Structure (TC_ITEM) Creating and Initializing a Tab Control Using a Tab Control Animate Controls: Class CAnimateCtrl Animate Control Styles Animate Control Notification Messages CAnimateCtrl Class Methods Creating and Initializing an Animate Control Using an Animate Control Rich Edit Controls: Class CRichEditCtrl Rich Edit Control Window Styles The Character Format Structure (CHARFORMAT) The Paragraph Format Structure (PARAFORMAT) CRichEditCtrl Class Methods CRichEditCtrl Line-Related Methods CRichEditCtrl Text-Selection Methods CRichEditCtrl Formatting Methods CRichEditCtrl Editing Methods CRichEditCtrl Clipboard Methods CRichEditCtrl General-Purpose Methods Creating and Initializing a Rich Edit Control Using a Rich Edit Control Summary Painting, Device Contexts, Bitmaps, and Fonts Device Contexts The Graphics Device Interface MFC Wrapping MFC Device Context Classes The Base Class: CDC Painting with Class CPaintDC Managing Client Areas with Class CClientDC Managing Frame Windows with Class CWindowDC Windows Graphic Objects Pens: Class CPen Brushes: Class CBrush Fonts: Class CFont Bitmaps: Class CBitmap Palettes: Class CPalette Regions: Class CRgn GDI Coordinate Systems Logical Mapping Modes Vector Graphics Drawing Modes Lines and Polylines Rectangles Regions Polygons Ellipses Bezier Curves Fonts and Text Font Characteristics The TEXTMETRIC Structure The LOGFONT Structure Font Creation Drawing Text Sample Program: Vector Graphics and Text Methods (VECTEXT1.EXE) Raster Graphics Named Raster Operations (ROPs) Bitmaps Device-Dependent Bitmaps Device-Independent Bitmaps (DIBs) The CBitmap Class Transferring and Contorting Bitmaps Bitmap Resources Tacking Resources onto an Executable File Getting Image Resources out of an Executable File Sample Program: Exploring Bitmap Resources (BITMAP1) Summary Custom Control Development Window Classes Versus C++ Classes A Validating Edit Control The Clock Static Control Control Metrics Painting the Face Locating the Hands Painting the Hands Setting the Time Pitfalls of Subclassing Standard Controls The Hyperlink Control Implementation Strategy Font Processing Painting the Window Controlling the Cursor Mouse Input Keyboard Input Launching the Link Advanced Custom Control Topics Subclassing Limitations Notifications Using the Resource Editor with Custom Classes Summary The MFC Application Object, Message Routing, and Idle Processing The MFC Application Object CWinApp and Application Lifetime The CWinApp Data Members The CWinApp Member Functions Application-Specific Initialization Functionality in InitInstance OLE Container Support 3D Look for Windows NT 3.5x Registry Usage Most Recently Used Files List SDI and MDI Document/View Main Frame Window Creation Automation Support Rich Edit Control Support Command-Line Handling Message Routing, Message Maps, and Message Categories Message Routing PreTranslateMessage Message Maps Idle Processing OnIdle Idle Processing for Dialogs The Splash Screen Component Summary Documents, Views, and Applications That Use Them The Document/View Architecture Documents, Frames, and Views Document Templates Creating New Documents Opening New Files Single Versus Multiple Document Templates Views The CView Class The CScrollView Class The CFormView Class The Database View Classes The Control Views Changing Views in an SDI Using the MDI Summary Extending the User Interface Responding to the User Keyboard Messaging Handling Keyboard Messages Mouse Messaging Handling Mouse Messages User Interfaces and AppWizard Extending Menus Obtaining Menus and Pop-up Menus Adding Menu Items Using Floating Pop-up Menus Putting Control Bars to Use Using Toolbars and Rebars Using Status Bars Showing and Hiding Control Bars Supporting ToolTips Updating the User Interface Property Sheets and Wizards MFC's Support for Property Sheets and Wizards Creating a Simple Wizard Splitting a View Summary Printing Printing Fundamentals Printing with MFC Printing in the View The PrintInfo Object Printing Menu Commands Printing and GDI Mapping Modes WYSIWYG Printing Application Resources The Application Class The View Class Pagination Printing with a Known Page Count Printing with an Unknown Page Count Printing Page Numbers Stopping and Aborting Print Jobs Halting a Print Job in OnPrepareDC() Halting a Print Job in OnPrint() Summary MFC and COM Programming COM A Little History Interfaces, Objects, and Methods Some Terminology A Real-World View The IUnknown Interface Servers, Clients, and Classes The COM Runtime Environment Defining the Class Factory How Are COM Objects Reused? Marshaling and Threading Marshaling Threading class view, 55-56 CListView class, 288 creating, 44 CRecordView class, 287 CRichEditView class, 288 CScrollView class, 286 CTreeView class, 287 CView class, 285 message routing, 261 methods, 43-44, 347-349 defined, 44 file view, 54-55 frame classes, 292-293 Icon view, 110 list view controls adding items to, 119 creating, 116-117 image lists, 113-114 implementing, 117-118 items/subitems, 114-115 notification messages, 116 supported views, 110-111 window styles, 112-113 OpenGL background erasure, 1051 CGLView class, 1043 creating, 1044-1047 destroying, 1047-1048 integrating into applications, 1052-1053 palette management, 1051-1052 sizing, 1048-1050 style bits, 1043 printing in, 347-349 DoPreparePrinting method, 348 OnBeginPrinting method, 348-349 OnEndPrinting method, 348-349 OnEndPrintPreview method, 348 OnPrepareDC method, 348-349 OnPreparePrinting method, 348 OnPrint method, 348-349 Report view, 111 resource view, 56-57 Small Icon icon, 111 splitting, 340-342 tree view controls creating, 123 implementing, 124 methods, 121-123 notification messages, 121 TREELIST sample application, 124 window styles, 120 UNL_Single sample application, 288-291 virtual key codes, 302 virtual memory, 1196 virtual tables (vtables), 20-21 VoIP (Voice-Over-IP), 998 VS_VERSION_INFO resource, 57 vtables (virtual tables), 20-21, 378, 1193 vtRet parameter (InvokeHelper method), 499 W War application (DirectSound demonstration), MainFrame.cpp source code file, 1147-1154 MainFrame.h header file, 1146-1147 Resource.h header file, 1144-1145 War.rc resource script, 1145 WAV files creating, 1132 CWave class, 1134-1140 playing, 1132-1133 Wave.cpp source code file (CWave class), 1135-1139 Wave.h header file (CWave class), 1134-1135 Web URLs (Uniform Resource Locators) hashes, 849 opening, 892-893 parsing, 911-913 Welcome page (WIZARD1.EXE application) CIntroPage class, 1210 fonts/text messages, 1211-1212 initializing, 1210-1211 template, 1206 wglCreateContext method, 1040, 1046 wglDeleteContext method, 1040 wglDestroyContext method, 1047 wglMakeCurrent method, 1040 what you see is what you get See WYSIWYG printing WHITENESS raster operation, 197 wide-character strings See also BSTRs conversion macros, 597-599 defined, 594 Width method, 175 Win32 API functions See functions window procedures, 9 windowed rendering (DirectDraw), 1111-1112 windows buddy windows, 88 CFrameWnd class message routing, 261 methods, 42-43 CWnd class, 34 container support, 572-573 methods, 36-39 registering, 35 creating, 11 destroying, 13 handles, 38 ownership, 38 registering, 11, 35 splash screens, 270-271 styles, 38 subclassing PreSubclassWindow method, 38 SubclassDlgItem method, 37 SubclassWindow method, 37 UnsubclassWindow method, 37 Windows Registry, 538, 1160-1162 See also RegSamp application API (appliction programming interface) functions, 1165-1167 RegCloseKey, 1165 RegCreateKey, 1165 RegDeleteKey, 1165 RegDeleteValue, 1165 RegEnumKey, 1165 RegEnumValue, 1165 RegFlushKey, 1165 RegLoadKey, 1165 RegNotifyChangeKeyValue, 1165 RegOpenKey, 1165 RegQueryInfoKey, 1165 RegSaveKey, 1165 wrapping, 1176 configuration data, 1162 CWinApp class methods GetAppRegistryKey, 30 GetProfileBinary, 31 GetProfileInt, 31 GetProfileString, 31 GetSectionKey, 30 RegCloseKey, 30 SetRegistryKey, 30, 254 WriteProfileBinary, 31 WriteProfileInt, 31 WriteProfileString, 31 keys, 1163 creating, 1168, 1171-1172 deleting, 1172-1174 HKEY_CLASSES_ROOT, 1164 HKEY_CURRENT_CONFIG, 1164 HKEY_CURRENT_USER, 1164 HKEY_DYN_DATA, 1164 HKEY_LOCAL_MACHINE, 1164 HKEY_USERS, 1164 name/value pairs, 1174-1176 Registry Key Editor dialog, 1167-1168 services information, 1162 state, 1162 user preferences, 1162 values, 1163 Windows common controls See common controls Windows Internet extensions See WinInit Windows messages See messages Windows Palette Manager, 163 WinInit (Windows Internet extensions), 889 base classes CInternetConnection, 901-902 CInternetException, 901 CInternetFile, 899-901 CInternetSession, 890-899 cookies retrieving, 896-897 setting, 895 exceptions, 901 files closing, 899 navigating, 900-901 opening, 899 read/write communications buffers, 901 reading, 900 writing, 900 FTP (File Transfer Protocol) client application directory navigation, 930-931 file listings, 929-930 file retrieval, 931-932 initialization, 926-928 server connection, 928-929 shell, 924-926 FTP (File Transfer Protocol) connections, 915 CFileFind, 918-920 CFtpConnection, 916-918 CFtpFileFind, 920-921 closing, 918 copying files, 916 deleting files, 918 directory navigation, 916, 930-931 downloading files, 917, 931-932 file attributes, 919-920 finding files, 918-921 GetFtpConnection method, 894-895 listing files, 929-930 opening files, 917 renaming files, 917 Gopher connections, 921 CGopherConnection, 922 CGopherFile, 924 CGopherFileFind, 924 CGopherLocator, 922-923 GetGopherConnection method, 895 locators, 922-923 HTTP (Hypertext Transfer Protocol) connections CHttpConnection, 911 CHttpConnection class, 910-913 CHttpFile, 913-915 CHttpFile class, 913 GetHttpConnection method, 893-894 requests closing, 914 headers, 913 retrieving information about, 914-915 sending, 914 sample application CMyInternetSession class definition, 903-904 dialog class pointer, 904 Internet sessions, starting/stopping, 906-908 shell, 902-903 status display, 904-906 session status indicators, 897-898 service types, 899 URLs (Uniform Resource Locators) opening, 892-893 parsing, 911-913 retrieving, 908-909 WinMain method, 10-11 Winsock, 853-855 dialog-based application, 869 CAsyncSocket class inheritance, 874-876 closing connections, 882-883 opening connections, 876-879 sending/receiving messages, 880-882 shell, 870 window layout, 871-873 initializing, 855 sockets blocking functions, 868-869 connections, opening/closing, 857-861 creating, 856-857 datagram, 857 error detection, 864-865 events, 862-864 messages, 859-861 network addresses, returning, 865-866 options, 866-868 serialization, 869 streaming, 857 wireframe, 1026 WIZARD1.EXE application (wizard example), 1205-1206 About You page CPage1 class, 1212-1214 methods, 1214-1216 SAMPLEWIZDATA structure, 1216-1217 template, 1207 Compiler Preferences page CPage2 class, 1218 template, 1207 dialog classes, 1209 displaying, 1219-1220 final page, 1208, 1218-1219 For for Thought page CPage3 class, 1217 template, 1207 Welcome page CIntroPage class, 1210 fonts/text messages, 1211-1212 initializing, 1210-1211 template, 1206 wizards, 1200-1202 AppWizard, 50, 309-310 Advanced Options dialog, 455 automation servers, 476-477 creating controls, 553 dialog boxes, 51-53 document servers, 450-452, 455, 462 enabling automation, 477 starting, 50 Support MFC option, 522-523 ATL Object Wizard, 606-610 creating controls, 554 Data Link Properties dialog, 688-689 OLE DB consumers, 687-690 Properties dialog, 688-689 property pages, 536 Select Database Table dialog, 689 ClassWizard automation servers, 477-483 property pages, 537 compared to property sheets, 326 ControlWizard creating controls, 541 property pages, 537 creating (Investment Wizard example), 329 class constructors, 333 class declarations, 333 global variables, 332-333 pages, 334-339 resource identifiers, 330-331 resources, 331-332 wizard classes, 339-340 displaying, 1204 notification messages PSN_WIZBACK, 1204 PSN_WIZFINISH, 1205 PSN_WIZNEXT, 1205 WIZARD1.EXE sample application, 1205-1206 About You page, 1207, 1212-1217 Compiler Preferences page, 1207, 1218 dialog classes, 1209 dialog template resources, 1208, 1218-1219 displaying, 1219-1220 Food for Thought page, 1207, 1217 Welcome page, 1206, 1210-1212 WM_ ERASEBKGND message, 1051 WM_CANCELMODE message, 234 WM_CHAR message, 234 WM_GETDLGCODE message, 235 WM_KEYDOWN message, 234 WM_KEYUP message, 234 WM_KICKIDLE message, 268-269 WM_MOUSEACTIVATE message, 307 WM_MOUSEHOVER message, 307 WM_MOUSELEAVE message, 307 WM_MOUSEMOVE message, 307 WM_MOUSEWHEEL message, 308 WM_NCHITTEST message, 232 WM_NOTIFY message, 83 WM_PAINT message, 1111 WM_PALETTECHANGED message, 1091-1092 WM_QUERYNEWPALETTE message, 1092-1093 WM_SETCURSOR message, 231 WM_SETFONT message, 228 WM_XBUTTONDBLCLK message, 308 WM_XBUTTONDOWN message, 308 WM_XBUTTONUP message, 308 Word wFlags argument (Invoke method), 471 worker threads, 25 workspaces adding projects to, 51 DAO (Data Access Objects), 678 defined, 51 wrapper classes, 34-35 wrapping Registry functions, 1176 Write method, 109, 565, 760, 900 write-only properties, 531 writeOnly value (CArchiveException::m_cause), 800 WriteProfileBinary method, 31 WriteProfileInt method, 31 WriteProfileString method, 31 WriteString method, 765, 900 WriteToFile method, 952 WYSIWYG (what you see is what you get) printing See also Shaper application application classes, 356-357 application resources keyboard accelerators, 356 menus, 354-355 toolbars, 355-356 view classes, 357-361 X-Y-Z x parameter (TabbedTextOut method), 194 y parameter (TabbedTextOut method), 194 ZIP code edit control FormatContents method, 216 implementation, 216-217 message map handler, 215-216 ... After all, that is why the book is titled MFC Programming with Visual C++ 6 Unleashed How This Book Is Organized This book is designed to be the most comprehensive MFC programming resource available anywhere today... Documents and views, and how to supercharge their use • MFC application user interface programming • MFC and printing • MFC as a COM server programming platform, including ActiveX programming • MFC as a COM client programming platform... architecture? That’s here too, as well as all other aspects of MFC programming In a nutshell, here is what you’ll find: • MFC s architecture and class layout • MFC as C++ • MFC as a Windows application programming tool • How to create compelling MFC applications

Ngày đăng: 25/03/2019, 16:05

Từ khóa liên quan

Mục lục

  • Part ICore MFC

  • Chapter 1The MFC Architecture

  • Chapter 2MFC Dialogs, Controls, and Data Interaction

  • Chapter 3The Windows Common Controls

  • Chapter 4Painting, Device Contexts, Bitmaps, and Fonts

  • Chapter 5Custom Control Development

  • Chapter 6The MFC Application Object, Message Routing, and Idle Processing

  • Part IIDocuments, Views, and Applications That Use Them

  • Chapter 7The Document/View Architecture

  • Chapter 8Extending the User Interface

  • Chapter 9Printing

  • Part IIIMFC and COM Programming

  • Chapter 10COM

  • Chapter 11COM and MFC

  • Chapter 12MFC OLE Servers

  • Chapter 13MFC OLE Clients

  • Chapter 14MFC ActiveX Controls

  • Chapter 15MFC ActiveX Control Containers

  • Chapter 16Using MFC and ATL

  • Chapter 17Scripting Your MFC Application

Tài liệu cùng người dùng

Tài liệu liên quan