Option Explicit On
Imports AxSftBoxLib45
Imports SftBoxLib45
Imports Softelvdm.OLEConvert
Public Class Form1
Inherits System.Windows.Forms.Form
Const vbDropEffectCopy As Integer = 1
Const vbDropEffectMove As Integer = 2
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents dragLabel As System.Windows.Forms.Label
Friend WithEvents comboTarget As AxSftBoxLib45.AxSftBox
Friend WithEvents label5 As System.Windows.Forms.Label
Friend WithEvents pictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents label4 As System.Windows.Forms.Label
Friend WithEvents label3 As System.Windows.Forms.Label
Friend WithEvents label2 As System.Windows.Forms.Label
Friend WithEvents comboSource As AxSftBoxLib45.AxSftBox
Friend WithEvents label1 As System.Windows.Forms.Label
Friend WithEvents closeButton As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.dragLabel = New System.Windows.Forms.Label
Me.comboTarget = New AxSftBoxLib45.AxSftBox
Me.label5 = New System.Windows.Forms.Label
Me.pictureBox1 = New System.Windows.Forms.PictureBox
Me.label4 = New System.Windows.Forms.Label
Me.label3 = New System.Windows.Forms.Label
Me.label2 = New System.Windows.Forms.Label
Me.comboSource = New AxSftBoxLib45.AxSftBox
Me.label1 = New System.Windows.Forms.Label
Me.closeButton = New System.Windows.Forms.Button
Me.label6 = New System.Windows.Forms.Label
CType(Me.comboTarget, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.pictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.comboSource, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'dragLabel
'
Me.dragLabel.Location = New System.Drawing.Point(7, 204)
Me.dragLabel.Name = "dragLabel"
Me.dragLabel.Size = New System.Drawing.Size(205, 23)
Me.dragLabel.TabIndex = 21
Me.dragLabel.Text = "Drag this text to the drop target"
'
'comboTarget
'
Me.comboTarget.AllowDrop = True
Me.comboTarget.Location = New System.Drawing.Point(263, 61)
Me.comboTarget.Name = "comboTarget"
Me.comboTarget.OcxState = CType(resources.GetObject("comboTarget.OcxState"), System.Windows.Forms.AxHost.State)
Me.comboTarget.Size = New System.Drawing.Size(227, 43)
Me.comboTarget.TabIndex = 20
'
'label5
'
Me.label5.Location = New System.Drawing.Point(58, 235)
Me.label5.Name = "label5"
Me.label5.Size = New System.Drawing.Size(278, 45)
Me.label5.TabIndex = 19
Me.label5.Text = "You can also drag file names from Windows Explorer to the drop target on the righ" & _
"t."
'
'pictureBox1
'
Me.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.pictureBox1.Image = CType(resources.GetObject("pictureBox1.Image"), System.Drawing.Image)
Me.pictureBox1.Location = New System.Drawing.Point(7, 235)
Me.pictureBox1.Name = "pictureBox1"
Me.pictureBox1.Size = New System.Drawing.Size(30, 30)
Me.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage
Me.pictureBox1.TabIndex = 18
Me.pictureBox1.TabStop = False
'
'label4
'
Me.label4.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.2!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.label4.Location = New System.Drawing.Point(7, 174)
Me.label4.Name = "label4"
Me.label4.Size = New System.Drawing.Size(241, 23)
Me.label4.TabIndex = 17
Me.label4.Text = "More Drag Sources"
'
'label3
'
Me.label3.Location = New System.Drawing.Point(263, 129)
Me.label3.Name = "label3"
Me.label3.Size = New System.Drawing.Size(227, 83)
Me.label3.TabIndex = 16
Me.label3.Text = "Drop items in the above combo box. The drop down portion will automatically beco" & _
"me visible as the cursor moves over the control."
'
'label2
'
Me.label2.Location = New System.Drawing.Point(7, 114)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(227, 53)
Me.label2.TabIndex = 15
Me.label2.Text = "Note: The drop down portion must be used to start a drag && drop from the above " & _
"combo box."
'
'comboSource
'
Me.comboSource.Location = New System.Drawing.Point(7, 61)
Me.comboSource.Name = "comboSource"
Me.comboSource.OcxState = CType(resources.GetObject("comboSource.OcxState"), System.Windows.Forms.AxHost.State)
Me.comboSource.Size = New System.Drawing.Size(227, 43)
Me.comboSource.TabIndex = 14
'
'label1
'
Me.label1.Location = New System.Drawing.Point(7, 8)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(395, 45)
Me.label1.TabIndex = 13
Me.label1.Text = "This sample shows OLE drag && drop. Simply drag data from the left (Drag Sources" & _
") to the combo box on the right (Drop Target)."
'
'closeButton
'
Me.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.closeButton.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.closeButton.Location = New System.Drawing.Point(409, 8)
Me.closeButton.Name = "closeButton"
Me.closeButton.Size = New System.Drawing.Size(88, 30)
Me.closeButton.TabIndex = 12
Me.closeButton.Text = "Close"
'
'label6
'
Me.label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.label6.Location = New System.Drawing.Point(231, 185)
Me.label6.Name = "label6"
Me.label6.Size = New System.Drawing.Size(266, 50)
Me.label6.TabIndex = 22
Me.label6.Text = "Click on the SftBox/OCX control above and hit F1 to access help information for S" & _
"ftBox/OCX 4.5"
Me.label6.Visible = False
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.CancelButton = Me.closeButton
Me.ClientSize = New System.Drawing.Size(504, 278)
Me.Controls.Add(Me.label6)
Me.Controls.Add(Me.dragLabel)
Me.Controls.Add(Me.comboTarget)
Me.Controls.Add(Me.label5)
Me.Controls.Add(Me.pictureBox1)
Me.Controls.Add(Me.label4)
Me.Controls.Add(Me.label3)
Me.Controls.Add(Me.label2)
Me.Controls.Add(Me.comboSource)
Me.Controls.Add(Me.label1)
Me.Controls.Add(Me.closeButton)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.Text = "Softel vdm, Inc. - DragDrop Sample"
CType(Me.comboTarget, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.pictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.comboSource, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
'--locate-marker--
Private Sub closeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeButton.Click
Application.Exit()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
comboSource.Items.Add("An Item")
comboSource.Items.Add("Another Item")
comboSource.Items.Add("Last Item")
comboSource.Columns.MakeOptimal(0)
comboSource.Items.RecalcHorizontalExtent(0)
comboTarget.Items.Add("A Source Item")
comboTarget.Items.Add("Another Source Item")
comboTarget.Items.Add("Last Source Item")
comboTarget.Columns.MakeOptimal(0)
comboTarget.Items.RecalcHorizontalExtent(0)
End Sub
Private Sub comboSource_DragStarting(ByVal sender As Object, ByVal e As AxSftBoxLib45._ISftBoxEvents_DragStartingEvent) Handles comboSource.DragStarting
comboSource.OLEDrag()
End Sub
Private Sub comboSource_OLEStartDrag(ByVal sender As Object, ByVal e As AxSftBoxLib45._ISftBoxEvents_OLEStartDragEvent) Handles comboSource.OLEStartDrag
e.allowedEffects = vbDropEffectCopy Or vbDropEffectMove
Dim textData As String = comboSource.get_Cell(comboSource.Items.Selection, 0).Text
e.data.SetData(textData, SftOLEClipboardConstants.sftCFText)
End Sub
Private Sub comboTarget_OLEDragOver(ByVal sender As Object, ByVal e As AxSftBoxLib45._ISftBoxEvents_OLEDragOverEvent) Handles comboTarget.OLEDragOver
If e.state = SftBoxOLEDragOverConstants.enterSftBox Then
' Show the drop down portion
comboTarget.DropDown.Dropped = True
ElseIf e.state = SftBoxOLEDragOverConstants.leaveSftBox Then
' Hide the drop down portion with a delay, in case the
' user is moving from/to the static or drop down portion
comboTarget.DropDown.RollUp(500) ' 1/2 second
End If
End Sub
Private Sub comboTarget_OLEDragDrop(ByVal sender As Object, ByVal e As AxSftBoxLib45._ISftBoxEvents_OLEDragDropEvent) Handles comboTarget.OLEDragDrop
If e.data.GetFormat(SftOLEClipboardConstants.sftCFText) Then
Dim itemIndex As Integer
itemIndex = comboTarget.Items.Insert(e.data.GetData(SftOLEClipboardConstants.sftCFText), comboTarget.Items.DropIndex)
comboTarget.Items.Selection = itemIndex
End If
If e.data.GetFormat(SftOLEClipboardConstants.sftCFBitmap) Then
Dim itemIndex As Integer
itemIndex = comboTarget.Items.Insert("A Bitmap", comboTarget.Items.DropIndex)
Dim o As Object = e.data.GetData(SftOLEClipboardConstants.sftCFBitmap)
comboTarget.get_Item(itemIndex).Image.Picture = o 'as stdole.IPictureDisp
comboTarget.Items.Selection = itemIndex
End If
If e.data.GetFormat(SftOLEClipboardConstants.sftCFFiles) Then
Dim itemIndex As Integer = -1
Dim toIndex As Integer = comboTarget.Items.DropIndex
Dim s As String
For Each s In e.data.Files
itemIndex = comboTarget.Items.Insert(s, toIndex)
toIndex = toIndex + 1
Next
comboTarget.Items.Selection = itemIndex
End If
comboTarget.Columns.MakeOptimal(0)
comboTarget.Items.RecalcHorizontalExtent(0)
End Sub
Private Sub dragLabel_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dragLabel.MouseDown
dragLabel.DoDragDrop(dragLabel.Text, DragDropEffects.Copy)
End Sub
Private Sub pictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pictureBox1.MouseDown
dragLabel.DoDragDrop(pictureBox1.Image, DragDropEffects.Copy)
End Sub
Friend WithEvents label6 As System.Windows.Forms.Label
End Class