Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $installDir = Split-Path -Path $myinvocation.mycommand.path
- & $env:SystemRootsystem32WindowsPowerShellv1.0powershell.exe -sta (Join-Path $installDir "TestDrop.ps1")
- ## TestDrop.ps1 for testing drag & drop
- function DragNDrop {
- #region Import the Assemblies
- [reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") | Out-Null
- [reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null
- [reflection.assembly]::Load("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") | Out-Null
- [reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") | Out-Null
- #endregion
- [System.Windows.Forms.Application]::EnableVisualStyles()
- $objForm = New-Object System.Windows.Forms.Form
- $objTextBox = New-Object System.Windows.Forms.TextBox
- $handler_DragEnter={
- write-host "$Event Enter"
- $Event.Effect = "Copy" # not sure about this ...
- }
- $objForm.Text = "Test Drag & Drop"
- $objForm.Size = New-Object System.Drawing.Size(200,200)
- $objForm.StartPosition = "CenterScreen"
- $objForm.KeyPreview = $True
- $objForm.SizeGripStyle = 'Hide'
- $objForm.FormBorderStyle = 'Fixed3D'
- $objTextBox.AllowDrop = $true
- $objTextBox.Location = New-Object System.Drawing.Size(10,25)
- $objTextBox.Size = New-Object System.Drawing.Size(120,120)
- $objTextBox.Multiline = $true
- $objTextBox.TabIndex = 1
- $objTextBox.Text = "Try to Drag & Drop File Here..."
- $objTextBox.Add_DragEnter({ write-host "Event Enter" })
- $objTextBox.Add_DragDrop({ write-host "Event Drop" })
- $objForm.Controls.Add($objTextBox)
- $objForm.Topmost = $True
- return $objForm.ShowDialog()
- } #End Function
- DragNDrop | Out-Null
- $objTextBox.Add_DragEnter({
- write-host "Event Enter"
- $_.Effect = 'Copy'
- })
Add Comment
Please, Sign In to add comment