BasicATLServer.zip
Basic ATL server.
-
Create an empty ATL server.
- Go to File/New/Projects/ATL COM AppWizard.
- Type in Project name "BasicATLServer", choose location, click OK.
- Leave defaults. Click Finish, OK.
-
Insert a main CoClass.
- In ClassView right-click on BasicATLServer classes, choose "New ATL Object", Simple Object, Next.
- Type in the Short Name "TheCoClass". Change interface to "IBasicAccess".
-
Add methods.
- With all the source files closed right click on IBasicAccess in the ClassView. Choose "Add method".
- Type method name
"getString", parameters "[out,retval] BSTR* theString", OK.
- Add protected member variable
"CComBSTR m_theString" to the TheCoClass.
- In ClassView right click on IBasicAccess. Choose "Add method".
- Type method name
"setString", parameters "[in] BSTR theString", OK.
- Modify
CTheCoClass constructor.
- Supply implementations of the
method functions.
- Build the project.
-
Build client application. Early binding.
- Create a spreadsheet "EarlyClient.xls"
- Open EarlyClient.xls, go to VBA editor, Tools/References/Browse.
Locate BasicATLServer.tlb and double click on it.
Locate "BasicATLServer 1.0 Type Library" in the list of available references
and check it in.
- Call the Sheet1's code module by double clicking on Sheet1.
Supply
the VBA code to
catch the "double click" event.
- Return to the spreadsheet view a experiment with double clicking. Observe that
double clicking on empty cell copies m_theString contents to the cell. Double clicking
on a non-mepty cell copies contents of the cell into the m_theString variable.
-
Build client application. Late binding.
Similar to the above effect may be achieved by supplying the
alternative code
for
the double click event handler.