SftTree/OCX 7.5 Documentation

Display
Print

ContentWindows Sample (VB6)

This sample illustrates content windows using Flash, Windows Media Player, Internet Explorer controls and forms.

The source code is located at C:\Program Files (x86)\Softelvdm\SftTree OCX 7.5\Samples\VB6\ContentWindows\Form1.frm or C:\Program Files\Softelvdm\SftTree OCX 7.5\Samples\VB6\ContentWindows\Form1.frm (on 32-bit Windows versions).

Dim SavedForm As Form2

Private Sub Form_Load()

    ' Flash
    ' Because some controls don't have a window handle property (like hWnd),
    ' we place the control inside a picturebox. A picturebox has a window
    ' handle property hWnd.
    ShockwaveFlash1.Movie = App.Path & "\header.swf"
    SftTree1.Item(3).Cell(1).AttachContentWindow FlashPictureBox.hWnd, contentWindowSftTreeKeepSize
    SftTree1.Item(3).Cell(1).Text = ""

    ' Windows Media Player
    WindowsMediaPlayer1.URL = App.Path & "\intermission.wmv"
    SftTree1.Item(4).Cell(1).AttachContentWindow WMPPictureBox.hWnd, contentWindowSftTreeKeepSize
    SftTree1.Item(4).Cell(1).Text = ""

    ' Web Browser
    WebBrowser1.Navigate "http://www.softelvdm.com"
    Dim Item As SftTreeItem
    Dim Cell As SftTreeCell
    Set Item = SftTree1.Item(5)
    Set Cell = Item.Cell(1)
    Cell.AttachContentWindow WebBrowserPictureBox.hWnd, contentWindowSftTreeNone
    Cell.Text = ""
    Item.MinHeightPix = 300 ' always exactly 300 pixels
    Item.MaxHeightPix = 300 ' always exactly 300 pixels

    SftTree1.RowHeaders.MakeOptimal ' Make row header width optimal, so text and pictures are not clipped horizontally.
    SftTree1.ColumnsObj.MakeOptimal ' Make all columns optimal

    ' Form
    Set SavedForm = New Form2
    SftTree1.Item(6).Cell(1).AttachContentWindow SavedForm.hWnd, contentWindowSftTreeKeepSize
    SftTree1.Item(6).Cell(1).Text = ""

    ' triple the size of the last column
    SftTree1.Column(1).WidthPix = SftTree1.Column(1).WidthPix * 3

    SftTree1.Items.RecalcHorizontalExtent ' Update horizontal scrollbar

    SftTree1.Items.Current = 0 ' select the first item
    SftTree1.Item(0).Selected = True

    Me.WindowState = 2 ' Maximize the main window
End Sub

Private Sub Form_Unload(Cancel As Integer)
    ' clean up
    Unload SavedForm
    Set SavedForm = Nothing
End Sub

Private Sub SftTree1_ItemCollapsed(ByVal ItemIndex As Long)
    If ItemIndex = 2 Then
        ' Here we make sure that the media stops playing when the control is not visible
        WindowsMediaPlayer1.Controls.pause
    End If
End Sub
Private Sub SftTree1_ItemExpanded(ByVal ItemIndex As Long)
    If ItemIndex = 2 Then
        ' Here we make sure that the media starts playing when the control is visible
        WindowsMediaPlayer1.Controls.Play
    End If
End Sub

Private Sub SftTree1_ItemDblClick(ByVal ItemIndex As Long, ByVal ColIndex As Integer, ByVal AreaType As Integer, ByVal Button As Integer, ByVal Shift As Integer)
    If AreaType = constSftTreeColumnRes Then
        SftTree1.Column(ColIndex).MakeOptimal
    End If
End Sub

Private Sub WebBrowserPictureBox_Resize()
    ' resize the web browser control (which is inside the picture box)
    ' every time the picture box is resized.
    WebBrowser1.Height = WebBrowserPictureBox.Height
    WebBrowser1.Width = WebBrowserPictureBox.Width
End Sub

Private Sub Form_Resize()
    ' let the tree control use up the entire window area
    SftTree1.Move 0, 0, ScaleWidth, ScaleHeight
End Sub


Last Updated 04/28/2018 - (email)
© 2018 Softel vdm, Inc.