How it Works

Internet Explorer User's Guide > Creating ActiveX Documents in Visual Basic

The code (below) is the complete source code for our first sample program. If you compare it to a similar VB sample program which runs as an .exe, you will notice 2 differences:

[Visual Basic 6]
Private Sub mnuAbout_Click()
   frmAbout.Show vbModal
End Sub
Private Sub TXTextControl1_Change()
   PropertyChanged "TextData"
End Sub
Private Sub UserDocument_Initialize()
   TXTextControl1.ButtonBarHandle = TXButtonBar1.hWnd
   TXTextControl1.StatusBarHandle = TXStatusBar1.hWnd
   TXTextControl1.RulerHandle = TXRuler1.hWnd
End Sub
Private Sub UserDocument_Resize()
   TXTextControl1.Height = ScaleHeight _
      - TXButtonBar1.Height - TXStatusBar1.Height _
      - TXRuler1.Height
End Sub
Private Sub UserDocument_ReadProperties(PropBag As PropertyBag)
   Dim TextData() As Byte
   TextData = PropBag.ReadProperty("TextData", "")
   TXTextControl1.LoadFromMemory TextData, 9
End Sub
Private Sub UserDocument_WriteProperties(PropBag As PropertyBag)
   Dim TextData() As Byte
   TextData = TXTextControl1.SaveToMemory(9)
   PropBag.WriteProperty "TextData", TextData
End Sub