You are previewing Programming with Microsoft Visual C++ .NET.
O'Reilly logo
Programming with Microsoft Visual C++ .NET

Book Description

The in-depth reference that covers both classic, core Windows competencies and modern .NET programming.

Learn how to write solid Visual C++ .NET code today with this comprehensive reference—the latest edition of the industry's most trusted text. It's the complete programming guide for intermediate and advanced developers who want to create .NET applications with Visual C++ and the Microsoft .NET Framework. Focusing on core programming techniques, instructions, and solutions, this book shows you what's new in Visual C++ .NET and walks you through the development life cycle with this powerful language. Get in-depth coverage of the language's syntax, tools, and APIs—along with expert advice and timesaving techniques. Take advantage of complete, task-based instruction plus your Microsoft Windows® and C++ programming skills to produce a new generation of killer Windows and .NET-based applications.

Table of Contents

  1. Copyright
  2. Dedication
  3. Acknowledgments
  4. Introduction
  5. Windows, Visual C++ .NET, and Application Framework Fundamentals
    1. Windows and Visual C++ .NET
      1. The Windows Programming Model
      2. Visual C++ .NET Components
      3. The Resource View Window and the Resource Editors
      4. The C/C++ Compiler
      5. The Source Code Editor
      6. The Resource Compiler
      7. The Linker
      8. The Debugger
      9. The MFC Application Wizard
      10. Class View
      11. Solution Explorer
      12. The Object Browser
      13. Unified Modeling Language Tools
      14. Online Help
      15. Windows Diagnostic Tools
      16. The MFC Library Version 7
      17. The ATL Library Version 7.0
      18. .NET Support
    2. The Microsoft Foundation Class Library Application Framework
      1. Why Use This Application Framework?
      2. What’s an Application Framework?
      3. MFC Library Message Mapping
      4. Documents and Views
  6. MFC Essentials
    1. Getting Started with the MFC Application Wizard
      1. What’s a View?
      2. MFC Library Application Types
      3. MFC Library User Interfaces
      4. Ex03a: The “Do-Nothing” Application
      5. The CEx03aView View Class
      6. Drawing Inside the View Window: The Windows GDI
      7. A Preview of the Resource Editors
      8. Win32 Debug Target vs. Win32 Release Target
      9. Understanding Precompiled Headers
      10. Two Ways to Run a Program
    2. Visual C++ .NET Wizards
      1. Wizard Types
      2. How Wizards Work
      3. Creating a Wizard
      4. Creating a Wizard for Developing Web Applications Using Managed C++
    3. Windows Message Mapping
      1. Getting User Input: Message Map Functions
      2. Using Windows Mapping Modes
      3. Creating a Scrolling View Window
      4. Using Other Windows Messages
    4. Classic GDI Functions, Fonts, and Bitmaps
      1. The Device Context Classes
      2. GDI Objects
      3. Fonts
      4. The Ex06a Example
      5. The Ex06b Example
      6. The Ex06c Example: CScrollView Revisited
      7. Bitmaps
      8. DIBs and the CDib Class
      9. Going Further with DIBs
      10. Putting Bitmaps on Pushbuttons
    5. Dialog Boxes
      1. Modal vs. Modeless Dialog Boxes
      2. Resources and Controls
      3. Programming a Modal Dialog Box
      4. Enhancing the Ex07a Application
      5. Identifying Controls: CWnd Pointers and Control IDs
      6. Setting the Dialog Box Background Color or a Control Color
      7. Adding Dialog Controls at Run Time
      8. Using Other Control Features
      9. Windows Common Dialog Boxes
      10. Programming a Modeless Dialog Box
    6. Common Controls
      1. Standard Common Controls
      2. The Ex08a Example: Standard Common Controls
      3. Advanced Common Controls
      4. The Ex08b Example: Advanced Common Controls
    7. Using ActiveX Controls
      1. ActiveX Controls vs. Ordinary Windows Controls
      2. Installing ActiveX Controls
      3. The Calendar Control
      4. ActiveX Control Container Programming
      5. The Ex09a Example: An ActiveX Control Dialog Container
      6. ActiveX Controls in HTML Files
      7. Creating ActiveX Controls at Run Time
      8. The Ex09b Example: The Web Browser ActiveX Control
      9. Picture Properties
      10. Bindable Properties: Change Notifications
    8. Win32 Core Memory Management
      1. Processes and Memory Space
      2. How Virtual Memory Works
      3. The VirtualAlloc Function: Committed and Reserved Memory
      4. The Windows Heap and the GlobalAlloc Function Family
      5. The Small-Block Heap, the C++ new and delete Operators, and _heapmin
      6. Memory-Mapped Files
      7. Accessing Resources
      8. Tips for Managing Dynamic Memory
      9. Optimizing Storage for Constant Data
    9. Windows Message Processing and Multi-Threaded Programming
      1. Windows Message Processing
      2. On-Idle Processing
      3. Multi-Threaded Programming
  7. MFC’s Document-View Architecture
    1. Menus, Keyboard Accelerators, the Rich Edit Control, and Property Sheets
      1. The Main Frame Window and Document Classes
      2. Windows Menus
      3. Keyboard Accelerators
      4. Command Processing
      5. The Application Framework’s Built-in Menu Commands
      6. MFC Text Editing Options
      7. The Ex12a Example
      8. Property Sheets
      9. The Ex12a Example Revisited
      10. The CMenu Class
      11. Creating Floating Shortcut Menus
      12. Extended Command Processing
    2. Toolbars and Status Bars
      1. Control Bars and the Application Framework
      2. Toolbars
      3. ToolTips
      4. Locating the Main Frame Window
      5. The Ex13a Example: Using Toolbars
      6. Status Bars
      7. The Ex13b Example: Using Status Bars
      8. Rebars
      9. The Ex13c Example: Using Rebars
    3. A Reusable Frame Window Base Class
      1. Why Reusable Base Classes Are Difficult to Write
      2. The CPersistentFrame Class
      3. The CFrameWnd::ActivateFrame Member Function
      4. The PreCreateWindow Member Function
      5. The Windows Registry
      6. Using the CString Class
      7. The Position of a Maximized Window
      8. Control Bar Status and the Registry
      9. Static Data Members
      10. The Default Window Rectangle
      11. The Ex14a Example: Using a Persistent Frame Window Class
      12. Persistent Frames in MDI Applications
    4. Separating the Document from Its View
      1. Document-View Interaction Functions
      2. The Simplest Document-View Application
      3. The CFormView Class
      4. The CObject Class
      5. Diagnostic Dumping
      6. The Ex15a Example: A Simple Document-View Interaction
      7. A More Advanced Document-View Interaction
      8. The CDocument::DeleteContents Function
      9. The CObList Collection Class
      10. The Ex15b Example: A Multi-View SDI Application
      11. Two Exercises for the Reader
    5. Reading and Writing Documents
      1. What Is Serialization?
      2. The SDI Application
      3. The Ex16a Example: SDI with Serialization
      4. Windows Explorer Launch and Drag and Drop
      5. MDI Support
      6. The Ex16b Example: An MDI Application
      7. MTI Support
      8. The Ex16c Example: An MTI Application
    6. Printing and Print Preview
      1. Windows-Based Printing
      2. Print Preview
      3. Programming for the Printer
      4. The Ex17a Example: A WYSIWYG Print Program
      5. Template Collection Classes Revisited: The CArray Class
      6. The Ex17b Example: A Multi-Page Print Program
    7. Splitter Windows and Multiple Views
      1. The Splitter Window
      2. View Options
      3. Dynamic and Static Splitter Windows
      4. The Ex18a Example: A Single View Class SDI Dynamic Splitter
      5. The Ex18b Example: A Double View Class SDI Static Splitter
      6. The Ex18c Example: Switching View Classes Without a Splitter
      7. The Ex18d Example: A Multiple View Class MDI Application
    8. Context-Sensitive Help
      1. WinHelp vs. HTML Help
      2. The Windows WinHelp Program
      3. The Application Framework and WinHelp
      4. A Help Example with No Programming Required
      5. Help Command Processing
      6. Example Ex19b: Help Command Processing
      7. MFC and HTML Help
      8. Example Ex19c: HTML Help
    9. Dynamic-Link Libraries
      1. DLL Fundamentals
      2. MFC DLLs: Extension vs. Regular
      3. The Ex20b Example: A DLL Test Client Program
      4. MFC Regular DLLs: The AFX_EXTENSION_MODULE Structure
      5. Using the AFX_MANAGE_STATE Macro
      6. The MFC Regular DLL Resource Search Sequence
      7. The Ex20c Example: An MFC Regular DLL
      8. Updating the Ex20b Example: Adding Code to Test Ex20c.dll
      9. A Custom Control DLL
    10. MFC Programs Without Document or View Classes
      1. The Ex21a Example: A Dialog Box–Based Application
      2. The Ex21b Example: An SDI Application
      3. The Ex21c Example: An MDI Application
  8. COM, Automation, ActiveX, and OLE
    1. The Component Object Model
      1. ActiveX Technology
      2. What Is COM?
      3. The Ex22a Example: Simulated COM
      4. Real COM with the MFC Library
      5. The Ex22b Example: An MFC COM In-Process Component
      6. The Ex22c Example: An MFC COM Client
      7. Containment vs. Aggregation vs. Inheritance
    2. Automation
      1. Creating C++ Components for VBA
      2. Automation Clients and Components
      3. Automation Interfaces
      4. Automation Programming Choices
      5. An MFC Automation Component
      6. An MFC Automation Client Program
      7. An Automation Client Program That Uses the Compiler’s #import Directive
      8. The VARIANT Type
      9. The COleVariant Class
      10. Automation Examples
      11. VBA Early Binding
    3. Uniform Data Transfer: Clipboard Transfer and OLE Drag and Drop
      1. The IDataObject Interface
      2. The FORMATETC and STGMEDIUM Structures
      3. IDataObject Interface Member Functions
      4. Other IDataObject Member Functions: Advisory Connections
      5. MFC UDT Support
      6. The MFC CRectTracker Class
      7. The Ex24a Example: A Data Object Clipboard
      8. MFC Drag and Drop
      9. The Ex24b Example: OLE Drag and Drop
    4. Introducing the Active Template Library
      1. Revisiting COM
      2. Writing COM Code
      3. The COM Infrastructure
      4. An ATL Roadmap
      5. Client-side ATL Programming
      6. Server-Side ATL Programming
      7. Attributed Programming
    5. ATL and ActiveX Controls
      1. What Are ActiveX Controls?
      2. Using ATL to Write an ActiveX Control
      3. Creating an Attributed Control
    6. The OLE DB Templates
      1. Why OLE DB?
      2. The Basic OLE DB Architecture
      3. The Basic OLE DB Template Architecture
      4. Creating an OLE DB Consumer
      5. Creating an OLE DB Provider
      6. Attributed OLE DB Programming
  9. Programming for the Internet
    1. Internet Essentials
      1. An Internet Primer
      2. Building an Intranet
      3. Winsock Programming
      4. Building a Web Server Using CHttpBlockingSocket
      5. Building a Web Client Using CHttpBlockingSocket
      6. WinInet
      7. Building a Web Client Using the MFC WinInet Classes
      8. Asynchronous Moniker Files
    2. Introducing Dynamic HTML
      1. The DHTML Object Model
      2. Visual C++ .NET and DHTML
      3. The Ex29a Example: MFC and DHTML
      4. The Ex29b Example: DHTML and MFC
      5. The Ex29c Example: ATL and DHTML
      6. For More Information
    3. ATL Server
      1. IIS
      2. ISAPI Server Extensions
      3. Enter ATL Server
      4. The Ex30a Example: An ATL Server Web Site
  10. .NET and Beyond
    1. Microsoft .NET
      1. Windows Component Technology
      2. The Common Language Runtime
    2. Managed C++
      1. The Common Language Runtime Is Your Friend
      2. Why Use C++?
      3. Managed C++ Extensions
      4. Visual C++ .NET and the Managed Extensions
      5. The Ex32a Example: A Managed C++ DLL Assembly
      6. Making the Assembly Usable
      7. The Ex32b Example: A Managed Client Executable
      8. Adding Managed Extension Support
    3. Programming Windows Forms Using Managed C++
      1. Windows Forms
      2. What’s Missing from Windows Forms
    4. Programming ASP.NET Using Managed C++
      1. The Internet as a Development Platform
      2. The Evolution of ASP.NET
      3. The Role of IIS
      4. ASP.NET’s Compilation Model
      5. The Page Class
      6. The HTTP Pipeline
      7. Web Services
    5. Programming ADO.NET Using Managed C++
      1. Managed Providers
      2. Working with the Providers
      3. ADO.NET Datasets
  11. Message Map Functions in the MFC Library
  12. MFC Library Runtime Class Identification and Dynamic Object Creation
    1. Getting an Object’s Class Name at Run Time
    2. The MFC CRuntimeClass Structure and the RUNTIME_CLASS Macro
    3. Dynamic Creation
    4. A Sample Program
  13. About the Author