Passing a custom object.
collectionServer.zip
-
Use a wizard to create an ATL project.
- In the Microsoft IDE go to File/New/Projects/ATL COM AppWizard.
- Choose location. Type the project name "collectionServer".
- Accept the defaults.
-
Add the collection CoClass
- In ClassView right click on "collectionServer classes" and
choose "New ATL Object".
- Choose the "Simple Object". Click "Next".
- Time the short name of the class: TheCoCollection.
Change Interface name to ISingleObject.
-
Add a custom object CoClass.
Repeate the above procedure. Supply the CoClass name TheCoData and the interface
name IData.
-
Populate IData interface with methods
- With source files closed right click on IData
- Choose "Add Method...".
- Supply method name getID.
- Supply parameters as "[out,retval] long* theID". Click OK.
- Repeat to supply
the rest
of the data access.
-
Populate ISingleObject interface with methods
Act as above. Provide
the methods.
Move (copy-paste) declaration of IData before uses of IData type in the
idl file.
-
Supply implementations.
- Supply member variable's declarations in the h files.
TheCoCollection.h
TheCoData.h
- Supply function implementations.
TheCoCollection.cpp
TheCoData.cpp
-
The client application.
See the collectionTest.xls.
Download on your hard drive and use VBAs Tools/References to check in the
server.