Share via


Adding Labels, Separator Lines, and Hyperlinks (C# Tutorial) [Office 2003 SDK Documentation]

Previous  Adding ActiveX Controls

The following steps show how to add labels, separator lines, and hyperlinks to the SimpleSample smart document.

  1. You will add the label, separator line, and hyperlink to the example element, so you don't need any additional constants, and you don't need to increase the number of types in the cTYPES constant. However, you need to insert the following code.

    In the ControlCount property subroutine, add 3 to the control count number for the cEXAMPLE constant. Replace the existing code in the cEXAMPLE case with the following code, or change your code to match:

                case cEXAMPLE:
                   intNumberOfControls = 4;
                   break;
    

    In the ControlTypeFromID property subroutine, insert the following code:

                case 202:
                   type = C_TYPE.C_TYPE_LABEL;
                   break;
    
                case 203:
                   type = C_TYPE.C_TYPE_SEPARATOR;
                   break;
    
                case 204:
                   type = C_TYPE.C_TYPE_LINK;
                   break;
    

    In the ControlCaptionFromID property subroutine, insert the following code:

                case 202:
                   strControlCaption = "This is a label. Below you " +
                      "will find a separator line and a hyperlink " +
                      "to the Microsoft home page.";
                   break;
    
                case 203:
                   strControlCaption = "This text doesn't show";
                   break;
    
                case 204:
                   strControlCaption = "Microsoft.com";
                   break;
    
  2. Use the InvokeControl method to specify actions for the hyperlink. For the SimpleSample smart document, you need to add a reference to the Microsoft Internet Controls. Then add the following variable and insert the following code into the Select Case statement in the InvokeControl method subroutine:

             SHDocVw.InternetExplorerClass objNav;
    
    ... [code between]
    
                case 204:
                   objNav = new SHDocVw.InternetExplorerClass();
                   objNav.Navigate("http://www.microsoft.com", ref objTemp, 
                      ref objTemp, ref objTemp, ref objTemp);
                   objNav.Visible = true;
                   break;
    

    Note  You can adjust the size of a separator line or the appearance of text in a label by placing code in the PopulateOther method and by using the Props parameter to specify the ISmartDocProperties key and value pairs. This is demonstrated in Adding ActiveX Controls.

  3. Recompile your SimpleSample smart document dynamic-link library (DLL), and copy it to the deployment location that you specified earlier.

  4. Because the Microsoft Internet Controls API is a COM interface and no primary interop assembly exists, Microsoft Visual Studio creates an interop assembly for you. You need to do the following to make sure your updated SimpleSample smart document functions properly:

    1. Copy that assembly to the deployment location.

    2. Add the following to the XML expansion pack manifest file (ManagedManifest.xml) that you created earlier. Within the SD:solution element for the SimpleSampleCS.clsActions solution action handler, directly under the closing element for the current SD:file element, paste the following text:

      <SD:file>
         <SD:type>other</SD:type>
         <SD:version>1.0</SD:version>
         <SD:filePath>INTEROP FILE NAME AND PATH GOES HERE</SD:filePath>
      </SD:file>
      
    3. Replace INTEROP FILE NAME AND PATH GOES HERE in the above text with the correct path where you are deploying the smart document and the interop assembly file name, for example, C:\SimpleSample\Interop.SHDocVw.dll.

  5. When you reopen your SimpleSample smart document, delete the SimpleSample XML expansion pack, and then re-add it to the document.

Next  C# Tutorial Overview