CSE775 - Distributed Objects

Lecture #12 - ATL and Building ATL-based Projects

Revised: 4/20/2011
Home Courses Code Handouts CoreTech Books Articles Math Research Masters Projects SWDev WebDev News OtherLinks SiteDesign Graduates AllPages Office Hours Notices Contents

CSE681-SWMAA CSE686-IP CSE687-OOD CSE775-DO CSE776-DP CSE778-AWP CSE784-SWS

Lecture #01 Lecture #02 Lecture #03 Lecture #04 Lecture #05 Lecture #06 Lecture #07
Lecture #08 Lecture #09 Lecture #10 Lecture #11 Lecture #12 Lecture #13 Lecture #14
Lecture #15 Lecture #16 Lecture #17 Lecture #18 Lecture #19 Lecture #20 Lecture #21
Lecture #22 Lecture #23 Lecture #24 Lecture #25 Lecture #26 Lecture #27 Lecture #28

Syllabus

Web Resources:

Code Project Win32, COM, MFC DevelopMentor Windows Developer's Journal Windows Forms GotDotNet C# Corner IDL and WDSL COM at MSDN IDL Language base MIDL types OLE data types IDL attributes MIDL data types MIDL Language Reference conversion functions

Office Hours:Instructor & TAs

Content:

This lecture is concerned with Active Template Library builds. We will also briefly discuss ATL wrapper classes for interface pointers, CComQIPtr, and BSTRs, CComBSTR.
  1. Syllabus
    Describes topics to be covered, reading material for you to digest before coming to class, and due dates for the assigned projects.
  2. Uploading Project Submissions
  3. All Distributed Objects Projects:

    Project #1, Project #2, Final Projects

  4. Two useful references for this material:
  5. Starting Active Template Library (ATL):
    Project simulating ATL Structure
    MSDN ATL Class Overview
    ATL Presentation
    Discusses the relationship between ATL modules and a component developed with ATL.

    ATL Interactive Demo We will walk through using ATL Wizard to build an in-process component and C# client.

    FirstATLsu10 Demo Project
    Demonstrates how to implement a simple in-proc ATL commponent.

    FirstATLsu10 step by step

  6. ATL Code Examples:
    ATL_Inproc_Ex1
    Our second ATL demonstration duplicates the raw C++ Inproc_Ex1 functionality. Here you will see CComBSTR and CComQIPtr in action.
    Building ATL_Inproc_Ex1

    FileHandler Component using SafeArray
    Uses SafeArray to marshal array of file names. Compare C++ client to C# client.

    Component Calls Component
    This document discusses briefly building a workspace with a client that calls a component that, in turn, calls another component.
    ComponentCallsComponent Project
    This Project shows you how to return an interface pointer from a COM interface.

    This project provides all the code used to generate screen shots for the presentation in the previous item. The code provides brief, but useful, examples of the CComQIPtr and CComBSTR classes. I believe this is the best way to build a client for components built with ATL.

    Marshaling Interface Pointers between Client Threads
    You can't pass interface pointers between apartments, without marshaling. To do so breaks the COM threading model. This project shows you how to do that.

  7. ATL Support for COM Clients:
    CComQIPtr
    A smart pointer the makes client code simpler and easier to maintain.
    CComBSTR
    BSTRs are rather ackward to manipulate, but wrapping a BSTR in a CComBSTR makes it almost as easy to use as a std::string object.
    CComSafeArray
    SafeArrays are the favored way of passing arrays through COM interfaces. If you want to pass an array from COM to a C# client you will have to use a SafeArray.
    CComVariant
    Variants are tagged unions that can hold most of the Windows types. They are similar to .Net Objects.
  8. ATL Windows:
    Frame window based on CWindowImpl<T>
    Dialog window based on CAxDialogImpl<T>
    atlctrls.h
    Provides small wrappers for a lot of Windows controls, shows how to crack messages.
    analysis of classes in atlctrls.h
    Listing of classes in atlctrls.h.
  9. ATL and WTL Tutorials:
  10. COM Interop:
  11. Out of Process COM Components: