Share via


Adding Labels, Separator Lines, and Hyperlinks (Visual Basic 6.0 Tutorial) [Office 2003 SDK Documentation]

Previous  Adding ActiveX Controls

The following steps show you 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
                ISmartDocument_ControlCount = 4
    

    In the ControlTypeFromID property subroutine, insert the following code.

            Case 202
                ISmartDocument_ControlTypeFromID = C_TYPE_LABEL
            Case 203
                ISmartDocument_ControlTypeFromID = C_TYPE_SEPARATOR
            Case 204
                ISmartDocument_ControlTypeFromID = C_TYPE_LINK
    

    In the ControlCaptionFromID property subroutine, insert the following code.

            Case 202
                ISmartDocument_ControlCaptionFromID = _
                    "This is a label. Below you will find a " & _
                    "separator line and a hyperlink to the " & _
                    "Microsoft home page."
            Case 203
                ISmartDocument_ControlCaptionFromID = _
                    "This text doesn't show"
            Case 204
                ISmartDocument_ControlCaptionFromID = _
                    "Microsoft.com"
    
  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.

    Dim objNav As InternetExplorer
    
    ... [code between]
    
            Case 204
                Set objNav = New SHDocVw.InternetExplorer
                objNav.Navigate2 "http://www.microsoft.com"
                objNav.Visible = True
    

    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 DLL, and copy it to the deployment location that you specified earlier. When you reopen your SimpleSample smart document, delete the SimpleSample XML expansion pack, and then re-add it to the document.

Next  Creating a Smart Document Using Microsoft Visual Basic 6.0 Introduction