SftTree/OCX 7.5 Documentation

Display
Print

ContentWindows Sample (C#)

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\Visual Studio - CSharp\ContentWindows\Form1.cs or C:\Program Files\Softelvdm\SftTree OCX 7.5\Samples\Visual Studio - CSharp\ContentWindows\Form1.cs (on 32-bit Windows versions).

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using SftTreeLib75;
using AxSftTreeLib75;
using Softelvdm.OLEConvert;

namespace ContentWindows {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {

            String path = System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(Application.ExecutablePath)));
            // Flash
            axShockwaveFlash1.Movie = path + "\\header.swf";
            axSftTree1.get_Item(3).get_Cell(1).AttachContentWindow((long) axShockwaveFlash1.Handle, SftTreeContentWindowStyleConstants.contentWindowSftTreeKeepSize);
            axSftTree1.get_Item(3).get_Cell(1).Text = "";

            // Windows Media Player
            axWindowsMediaPlayer1.URL = path + "\\intermission.wmv";
            axSftTree1.get_Item(4).get_Cell(1).AttachContentWindow((long) axWindowsMediaPlayer1.Handle, SftTreeContentWindowStyleConstants.contentWindowSftTreeKeepSize);
            axSftTree1.get_Item(4).get_Cell(1).Text = "";

            // Web Browser
            webBrowser1.Navigate("http://www.softelvdm.com");
            SftTreeItem Item= axSftTree1.get_Item(5);
            SftTreeCell Cell = Item.get_Cell(1);
            Cell.AttachContentWindow((long)webBrowserPanel.Handle, SftTreeContentWindowStyleConstants.contentWindowSftTreeNone);
            Cell.Text = "";
            Item.MinHeightPix = 300; // always exactly 300 pixels
            Item.MaxHeightPix = 300; // always exactly 300 pixels

            // Form
            FormSmall f = new FormSmall();
            axSftTree1.get_Item(6).get_Cell(1).AttachContentWindow((long)f.Handle, SftTreeContentWindowStyleConstants.contentWindowSftTreeKeepSize);
            axSftTree1.get_Item(6).get_Cell(1).Text = "";

            axSftTree1.RowHeaders.MakeOptimal(); // Make row header width optimal, so text and pictures are not clipped horizontally.
            axSftTree1.ColumnsObj.MakeOptimal(); // Make all columns optimal

            // triple the size of the last column
            axSftTree1.get_Column(1).WidthPix = axSftTree1.get_Column(1).WidthPix * 3;

            axSftTree1.Items.RecalcHorizontalExtent(); // Update horizontal scrollbar

            axSftTree1.Items.Current = 0; // select the first item
            axSftTree1.get_Item(0).Selected = true;

            axSftTree1.Dock = DockStyle.Fill; // Maximize the main window

            this.WindowState = FormWindowState.Maximized;
        }

        private void axSftTree1_ItemExpanded(object sender, _DSftTreeEvents_ItemExpandedEvent e) {
            if (e.itemIndex == 2)
                axWindowsMediaPlayer1.Ctlcontrols.play();
        }

        private void axSftTree1_ItemCollapsed(object sender, _DSftTreeEvents_ItemCollapsedEvent e) {
            if (e.itemIndex == 2)
                axWindowsMediaPlayer1.Ctlcontrols.pause();
        }

        private void axSftTree1_ItemDblClick(object sender, _DSftTreeEvents_ItemDblClickEvent e) {
            if (e.areaType == (short) SftTreeAreaTypeConstants.constSftTreeColumnRes) {
                axSftTree1.get_Column(e.colIndex).MakeOptimal();
            }
        }
    }
}

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