BasicATLServer.zip

Basic ATL server.

  1. Create an empty ATL server.

    1. Go to File/New/Projects/ATL COM AppWizard.
    2. Type in Project name "BasicATLServer", choose location, click OK.
    3. Leave defaults. Click Finish, OK.

  2. Insert a main CoClass.

    1. In ClassView right-click on BasicATLServer classes, choose "New ATL Object", Simple Object, Next.
    2. Type in the Short Name "TheCoClass". Change interface to "IBasicAccess".

  3. Add methods.

    1. With all the source files closed right click on IBasicAccess in the ClassView. Choose "Add method".
    2. Type method name "getString", parameters "[out,retval] BSTR* theString", OK.
    3. Add protected member variable "CComBSTR m_theString" to the TheCoClass.
    4. In ClassView right click on IBasicAccess. Choose "Add method".
    5. Type method name "setString", parameters "[in] BSTR theString", OK.
    6. Modify CTheCoClass constructor.
    7. Supply implementations of the method functions.
    8. Build the project.

  4. Build client application. Early binding.

    1. Create a spreadsheet "EarlyClient.xls"
    2. 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.
    3. Call the Sheet1's code module by double clicking on Sheet1. Supply the VBA code to catch the "double click" event.
    4. 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.

  5. Build client application. Late binding.

    Similar to the above effect may be achieved by supplying the alternative code for the double click event handler.
Hosted by www.Geocities.ws

1