本书是《微软编程圣典丛书(影印版)》之一,讲述如何在32位Windows平台上使用MFC(微软基本类库)进行程序设计,内容涉及全新COM、OLE和ActiveX,事件驱动程序设计,位图,多线程等。为了增加本书的实用性,特以配套光盘的形式提供了丰富的程序实例以及本书的电子版。\r\n 本书由微软公司组织专家编写,具有相当的技术深度,是中、高级程序员必备的参考书。\r\n Microsoft强大的C++类库可以用于Windows API,本书对其中被公认为具有权威性的部分作了扩充说明,用全新的COM、OLE和ActiveX更新了旧的内容。对MFC编程的基本概念和技巧作了精湛的阐述,然后说明了如何将它们熟练地用于32位Windows平台上的面向对象的开发。\r\n 配套光盘内容:本书示例程序的源代码及可执行程序,本书电子版。\r\n
Acknowledgments\r\nIntroduction\r\n\r\nPart 1 Fundamentals of Widnows and MFC\r\n\r\nCapter 1 Hello,MFC\r\n\r\nTHE WINDOWS PROGRAMMING MODEL\r\nMessages,Messages,and More Messages\r\nWidnows Programming ,SDK-Style\r\nHungarian Notation and Windows Data Types\r\nSDK Programming in Perspective\r\nINTRODUCING MFC\r\nThe Benefits of Using C++ and MFC\r\nThe MFC Design Philosophy\r\nThe Document/View Architecture\r\nThe MFC Class Hierarchy\r\nAFX Functions\r\nYOUR FIRST MFC APPLICATION\r\nThe Application Object\r\nHow MFC Uses the Application Object\r\nThe Frame Window Object\r\nPainting the Window\r\nThe Message Map\r\nHow Message Maps Work\r\nWidnows,Character Sets,and the_T Macro\r\nBuilding the Application\r\nThe Big Picture\r\n\r\nChapter 2 Drawing in a Window\r\n\r\nTHE WINDOWS GDI\r\nThe MFC Device Context Classes\r\nDevice Context Attributes\r\nThe Drawing Mode\r\nThe Mapping Mode\r\nProgrammable Mapping Modes\r\nCoordinate Conversions\r\nMoving the Origin\r\nA Final Word on Coordinate Systems\r\nGetting Information About a Device\r\nDRAWING WITH THE GDI\r\nDrawing Lines and Curves\r\nDrawing Ellipses,Polygons,and Other Shapes\r\nGDI Pens and the CPen Class\r\nGDI Brushes and the CBrush Class\r\nDrawing Text\r\nGDI Fonts and the CFont Class\r\nRaster Fonts vs. TrueType Fonts\r\nRotated Text\r\nStock Objects\r\nDeleting GDI Objects\r\nDeselecting GDI Objects\r\nThe Ruler Application\r\nSEEING WHAT YOU’VE DRAWN\r\nAddign a Scroll Bar to a Window\r\nSetting a Scroll Bar’s Range,Position,and Page Size\r\nSynchronizing the Thumb Size and the Window Size\r\nProcessing Scroll Bar Messages\r\nScrolling a Window\r\nThe Accel Application\r\nLOOSE ENDS\r\n\r\nChapter 3 The Mouse and the Keyboard\r\n\r\nGETTING INPUT FROM TEH MOUSE\r\nClient-Area Mouse Messages\r\nThe TicTac Application\r\nNonclient-Area Mouse Messages\r\nThe WM_NCHITTEST Message\r\nThe WM_MOUSELEAVE and WM_MOUSEHOVER Messages\r\nThe Mouse Wheel\r\nCapturing the Mouse\r\nMouse Capturing in Action\r\nThe Cursor\r\nThe Hourglass Cursor\r\nMouse Miscellanea\r\nGETTING INPUT FROM THE KEYBOARD\r\nThe Input Focus\r\nKeystroke Messages\r\nVirtual Key Codes\r\nShift States and Toggles\r\nCharacter Messages\r\nDead-Key Messages\r\nThe Caret\r\nTHE VISUALKB APPLICATION\r\nHandling the Caret\r\nEntering and Editing Text\r\nOther Points of Interest\r\n\r\nChapter 4 Menus\r\n\r\nMENU BASICS\r\nCreating a Menu\r\nLoading and Displaying a Menu\r\nResponding to Menu Commands\r\nCommand Ranges\r\nUpdating the Items in a Menu\r\nUpdate Ranges\r\nKeyboard Accelerators\r\nTHE SHAPES APPLICATION\r\nRunning the MFC AppWizard\r\nAnalyzing AppWizard’s Output\r\nBeyond AppWizard\r\nThe Process in Review\r\nMENU MAGIC\r\nCreating Menus Programmatically\r\nModifying Menus Programmatically\r\nThe System Menu\r\nOwner-Draw Menus\r\nCascading Menus\r\nContext Menus\r\nTHE COLOR APPLICATION\r\nThe Context Menu\r\nOn Your Own\r\n\r\nChapter 5 The MFC Collection Classes\r\n\r\nARRAYS\r\nThe MFC Array Classes\r\nDynamic Array Sizing\r\nCreating Type-Safe Array Classes with CArray\r\nLISTS\r\nThe MFC List Classes\r\nCreating Type-Safe List Classes with CList\r\nMAPS\r\nThe MFC Map Classes\r\nHow Maps Work\r\nOptimizing Lookup Efficency\r\nCreating Type-Safe Map Classes with CMap\r\nTHE TYPED POINTER CLASSES\r\n\r\nChapter 6 File I/O and Serialization\r\n\r\nTHE CFILE CLASS\r\nOpening,Closing,and Creating Files\r\nReading and Writing\r\nCFile Derivatives\r\nEnumerating Files and Folders\r\nSERIALIZATION AND THE CARCHIVE CLASS\r\nSerialization Basics\r\nWriting Serializable Classes\r\nVersioning Serializable Classes:Versionable Schemas\r\nHow Serialization Works\r\nSerializing CObjects\r\n\r\nChapter 7 Controls\r\n\r\nTHE CLASSIC CONTROLS\r\nThe CButton Class\r\nThe CListBox Class\r\nThe CStatic Class\r\nThe FontView Application\r\nThe CEdit Class\r\nPresto!Instant Notepad\r\nThe CComboBox Class\r\nThe CScrollBar Class\r\nADVANCED CONTROL PROGRAMMING\r\nNumeric Edit Controls\r\nOwner-Draw List Boxes\r\nGraphical Push Buttons\r\nCustomizing a Control’s Colors\r\nMessage Reflection \r\n\r\nChapter 8 Dialog Boxes and Property Sheets\r\n\r\nMODAL DIALOG BOXES AND THE CDIALOG CLASS\r\nThe Dialog Box Template\r\nThe CDialog Class\r\nCreating a Modal Dialog Box\r\nDialog Data Exchange and Dialog Data Validation\r\nInteracting with the Controls in a Dialog\r\nThe DlgDemo1 Application\r\nMODELESS DIALOG BOXES\r\nThe DlgDemo2 Application\r\nUSING A DIALOG BOX AS A MAIN WINDOW\r\nPROPERTY SHEETS\r\nThe PropDemo Application\r\nTHE COMMON DIALOGS\r\nModifying the Common Dialogs\r\nThe Phones Application\r\n\r\nPart II The Document/View Architecture\r\n\r\nChapter 9 Documents,Views,and the Single Document Interface\r\n\r\nDOCUMENT/VIEW FUNDAMENTALS\r\nThe InitInstance Function Revisited\r\nThe Document Object\r\nThe View Object\r\nThe Frame Window Object\r\nDynamic Object Creation\r\nMore on the SDI Document Types with the Operating System Shell\r\nCommand Routing\r\nPredefined Command IDs and Command Handlers\r\nYOUR FIRST DOCUMENT/VIEW APPLICATION\r\nThe SdiSquares Application\r\nSdiSpuares Step by Step\r\nDOC+VIEW=LESS WORK FOR YOU\r\n\r\nChapter 10 Scroll Views,HTML Views,and Other View Types\r\n\r\nSCROLL VIEWS\r\nCScrollView Basics\r\nCScrollView Operations\r\nOptimizing Scrolling Performance\r\nThe ScrollDemo Application\r\nConverting and Ordinary View into a Scroll View\r\nHTML VIEWS\r\nCHtmlView Operations\r\nCHtmlView Overridables\r\nUtilizing DHTML in CHtmlView-Based Applications\r\nTree Views\r\nInitializing a Tree View\r\nTree View Member Functions and Notifications\r\nThe DriveTree Application\r\nLIST VIEWS\r\nInitializing a List View\r\nChanging the Presentation Style\r\nSorting in a List View\r\nHit-Testing in a List View\r\nThe WinDir Application\r\nDO-IT-YOURSELF CONTROL VIEWS\r\n\r\nChapter 11 Multiple Documents and Multiple Views\r\n\r\nMFC AND THE MULTIPLE DOCUMENT INTERFACE\r\nSynchronizing Multiple Views of a Document\r\nThe MdiSquares Application\r\nSupporting Multiple Document Types\r\nAleternatives to MDI\r\nSPLITTER WINDOWS\r\nDynamic Splitter Windows\r\nThe Sketch Application\r\nStatic Splitter Windows\r\nThe Wanderer Application\r\nCustom Command Routing\r\nThree-Way Splitter Windows\r\nDynamic Splitter Windows with Multiple View Types\r\n\r\nChapter 12 Toolbars,Status Bars,and Rebars\r\n\r\nTOOLBARS\r\nCreating and Initializing a Toolbar\r\nDocking and Floating\r\nControlling a Toolbar’s Visibility\r\nKeeping Toolbar Buttons in Sync with Your Application\r\nAdding ToolTips and Flyby Text\r\nAdding Non-Push-Button Controls to a Toolbar\r\nUpdating Non-Push-Button Controls\r\nMaking Toolbar Settings Persistent\r\nToolbar Support in AppWizard\r\nSTATUS BARS\r\nCreating and Initializing a Status Bar\r\nProviding Context-Sensitive Help for Menu Items\r\nCreating Custom Status Bar Panes\r\nStatus Bar Support in AppWizard\r\nPUTTING IT ALL TOGETHER:THER MYWORD APPLICATION\r\nThe Main Toolbar\r\nThe Sytle Bar\r\nMore About CRichEditView\r\nREBARS\r\n\r\nChapter 13 Printing and Print Previewing\r\n\r\nPRINTING WITH DOCUMENTS AND VIEWS\r\nThe Windows Print Architecture\r\nThe MFC Print Architecture\r\nPrint Previewing\r\nA BARE-BONES PRINTING APPLICATION\r\nBlack-and-White Print Previews\r\nA MORE COMPLEX PRINTING APPLICATION\r\nA Unique Approach to Serialization\r\nPRINTING TIPS AND TRICKS\r\nUsing the Print Dialog’s Selection Button\r\nAssume Nothing-And Test Thoroughly!\r\nAdding Default Pagination Support\r\nEnumerating Printers\r\n\r\nPart III Beyond the Basics\r\n\r\nChapter 14 Timers and Idle Processing\r\n\r\nTIMERS\r\nSetting a Timer:Method 1\r\nResponding to WM_TIMER Messages\r\nSetting a Timer:Method 2\r\nStopping a Timer\r\nTHE CLOCK APPLICATION\r\nProcessing Timer Messages\r\nGetting the Current Time:The CTime Class\r\nUsing the MM_ISOTROPIC Mapping Mode\r\nHiding and Displaying the Title Bar\r\nImplementing Client-Area Drag\r\nUsing the System Menu as a Context Menu\r\nTopmost Windows\r\nMaking Configuration Settings Persistent\r\nControlling the Window Size:The WM_GETMINMAXINFO Message\r\nIDLE PROCESSING\r\nUsing OnIdle\r\nIdle Processing vs.Multithreading\r\n\r\nChapter 15 Bitmaps,Palettes,and Regions\r\n\r\nPALETTES\r\nHow Windows Uses Color\r\nLogical Palettes and the CPalette Class\r\nCreating a Logical Palette\r\nRealizing a Logical Palette\r\nDrawing with Palette Colors\r\nThe WM_QUERYNEWPALETTE and WM_PALETTECHANGED Messages\r\nDetermining Whether a Logical Palette Is Needed\r\nThe PaletteDemo Application\r\nPalette Animation\r\nThe::SetSystemPaletteUse Function\r\nBITMAPS\r\nDDBs and the CBitmap Class\r\nBlitting Bitmaps to Screens and Other Devices\r\nBitmap Resources\r\nDIBs and DIB Sections\r\nBlits,Raster Operations,and Color Mapping\r\nThe BitmapDemo Application\r\nWriting a BMP File Viewer\r\nMore on the ::LoadImage Function\r\nREGIONS\r\nRegions and the CRgn Class\r\nThe RegionDemo Application\r\n\r\nChapter 16 The Common Controls\r\n\r\nCOMMON CONTROL FUNDAMENTALS\r\nCreating a Common Control\r\nProcessing Notifications:The WM_NOTIFY Message\r\nSLIDER,SPIN BUTTON,AND TOOL TIP CONTROLS\r\nSlider Controls\r\nSpin Button Controls\r\nToolTip Controls\r\nThe GridDemo Application\r\nIMAGE LISTS AND COMBOBOXEX CONTROLS\r\nImage Lists\r\nComboBoxEx Controls\r\nThe PathList Application\r\nPROGRESS CONTROLS AND ANIMATION CONTROLS\r\nProgress Controls\r\nAnimation Controls\r\nIP ADDRESS CONTROLS AND OTHER DATA-ENTRY CONTROLS\r\nIP Address Controls\r\nHotkey Controls\r\nMonth Calendar Controls\r\nDate-Time Picker Controls\r\n\r\nChapter 17 Threads and Thread Synchronization\r\n\r\nTHREADS\r\nCreating a Worker Thread\r\nCreating a UI Thread\r\nSuspending and Resuming Threads\r\nPutting Threads to Sleep\r\nTerminating a Thread\r\nAutodeleting CWinThreads\r\nTerminating Another Thread\r\nThreads,Processes,and Priorities\r\nUsing C Run-Time Functions in Multithreaded Applications\r\nCalling MFC Member Functions Across Thread Boundaries\r\nYour First Multithreaded Application\r\nTHREAD SYNCHRONIZATION\r\nCritical Sections\r\nMutexes\r\nEvents\r\nSemaphores\r\nThe CSingleLock and CMultiLock Classes\r\nWriting Thread-Safe Classes\r\nThe ImageEdit Application\r\nODDS AND ENDS\r\nMessage Pumps\r\nLaunching Other Processes\r\nFile Change Notifications\r\n\r\nPart IV COM,OLE,and ActiveX\r\n\r\nChapter 18 MFC and the Component Object Model\r\n\r\nTHE COMPONENT OBJECT MODEL\r\nInstantiating a COM Object\r\nObject Lifetimes\r\nAcquiring Interface Pointers\r\nCOM Servers\r\nLocation Transparency\r\nObject Linking and Embedding\r\nActive Documents\r\nActiveX\r\nMFC AND COM\r\nMultiple Inheritance\r\nNested Classes\r\nMFC and Nested Classes\r\nHow MFC Implements IUnknown\r\nInterface Maps\r\nMFC and Aggregation\r\nMFC and Class Factories\r\nPutting It All in Perspective\r\n\r\nChapter 19 The Clipboard and OLE Drag-and-Drop\r\n\r\nTHE LEGACY CLIPBOARD\r\nClipboard Formats\r\nPrivate Clipboard Formats\r\nProviding Data in Multiple Formats\r\nQuerying for Available Data Formats\r\nDelayed Rendering\r\nBuilding a Reusable Clipboard Class\r\nTHE OLE CLIPBOARD\r\nOLE Clipboard Basics\r\nMFC,Global Memory,and the OLE Clipboard\r\nUsing Alternative Storage Media\r\nTreating the OLE Clipboard as a CFile\r\nMultiple Formats and Multiple Storage Media\r\nChecking Data Availability\r\nDelayed Rendering with COleDataSource\r\nCOleDataSource and COleDataObject in Review\r\nOLE DRAG-AND-DROP\r\nAnatomy of a Drop Source\r\nAnatomy of a Drop Target\r\nMFC Support for OLE Drag-and-Drop\r\nDrop Target Scrolling\r\nPUTTING IT ALL TOGETHER:THE WIDGET APPLICATION\r\nThe AfxOleInit Function\r\n\r\nChapter 20 Automation\r\n\r\nAUTOMATION BASICS\r\nIDispatch:The Root of All Automation\r\nAutomation Data Types\r\nLate Binding vs.Early Binding\r\nDual Interfaces\r\nType Libraries\r\nMFC AUTOMATION SERVERS\r\nMFC,IDispatch,and Dispatch Maps\r\nWriting an Automation Server\r\nAdding Automation Methods\r\nAdding Automation Properties\r\nA Simple Automation Server\r\nAutomation Hierarchies\r\nA More Complex Automation Server\r\nMFC AUTOMATION CLIENTS\r\nThe PieClient Application\r\nConnecting to a Running Automation Server\r\n\r\nChapter 21 ActiveX Controls\r\n\r\nACTIVEX CONTROL BASICS\r\nMethods,Properties,and Events\r\nCustom vs.Stock\r\nAmbient Properties\r\nControl States\r\nThe ActiveX Control Architecture\r\nActiveX Control Containers\r\nMFC Support for ActiveX Controls\r\nBUILDING ACTIVEX CONTROLS\r\nRunning ControlWizard\r\nImplementing OnDraw\r\nUsing Ambient Properties\r\nAdding Methods\r\nAdding Properties\r\nAdding Properties Persistent\r\nCustomizing a Control’s Property Sheet\r\nAdding Pages to a Control’s Property Sheet\r\nAdding Events\r\nEvent Maps\r\nBuilding an ActiveX Control\r\nTesting and Debugging an ActiveX Control\r\nRegistering an ActiveX Control\r\nUSING ACTIVEX CONTROLS IN MFC APPLICATIONS\r\nCalling an ActiveX Control’s Methods\r\nProcessing Events\r\nThe CalUser Application\r\nUsing ActiveX Controls in Nondialog Windows\r\nUsing ActiveX Controls in Web Pages\r\nADVANCED TOPICS\r\nWindowless Controls\r\nControl Subclassing\r\nControl Licensing\r\n\r\nIndex