Share via


Step 3: Creating the SimpleSample DLL (Visual C++ Tutorial) [Office 2003 SDK Documentation]

Previous  Step 2: Setting up the Visual C++ project

The smart document dynamic-link library (DLL) contains the actions and logic for the smart document. The following section shows how to create a smart document DLL by using Microsoft Visual C++.

  1. Open the Actions.cpp file, and insert the code for the smart document constants.

    Important   If you copied the entire code from the SimpleSample Smart Document Code Module, you can jump ahead to step 5. However, you may want to read through to step 5 to understand what each of the subroutines does.

  2. Insert the SmartDocInitialize method. (There is no code to insert into this method.)

  3. Define the number of types (or elements) that will have controls and actions assigned to them. For the SimpleSample smart document, there is one type, cTEXTBOX.

    • Insert the code for the SmartDocXmlTypeCount property to specify the number of elements that will have controls and actions assigned to them.

      Note  To insert the SmartDocXMLTypeCount property or any of the other properties and methods in the ISmartDocument interface into your code, select SmartDocXmlTypeCount from the Procedures list (the drop-down list to the right of and above the code view) to add the SmartDocXmlTypeCount property to your code module.

    • Insert the code for the SmartDocXmlTypeName property to assign names to the element constants that you specified earlier.

    • Insert the code for the SmartDocXmlTypeCaption property to specify the caption that is displayed in the Document Actions task pane for the type.

  4. Define the number of controls for each of the types specified above. Each type can have one or more controls associated with it, and each of those controls can be any of the controls specified in the C_TYPE constants.

    • Insert the code for the ControlCount property to specify the number of controls that you want to create for each of the types specified earlier.

    • Insert the code for the ControlID property to provide a unique identifier for each of the controls in the smart document.

    • Insert the code for the ControlNameFromID property to specify a friendly name that you can use to access each of your controls from the application's Microsoft Visual Basic for Applications (VBA) object model.

    • Insert the code for the ControlCaptionFromID property to specify the caption displayed in the Document Actions task pane for each of the controls.

    • Insert the code for the PopulateTextboxContent method to specify what happens when the control is displayed.

      Note  This subroutine is empty because we aren't specifying any actions for the text box when it is initially displayed in the Document Actions task pane. However, by using the PopulateTextboxContent method, you could initially populate a text box with data from a database or another source.

    • Insert the code for the OnTextboxContentChange method to specify what happens when the contents of the text box control change.

  5. This is all the code necessary for the first part of the SimpleSample smart document.  However, the ISmartDocument interface requires that all methods and properties be present regardless of whether they contain code. Therefore, add blank subroutines for the remaining methods.

    Note  You can determine which procedures are unused by opening the Procedure drop-down list, to the top right of the code view, and selecting each of the items that are not bold. (Items that are not bold are the unused procedures in the interface.)

Next   Step 4: Compiling the SimpleSample DLL