<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[FalconIA's BLOG]]></title> 
<link>http://falconia.org/blog/index.php</link> 
<description><![CDATA[FalconIA's Studio]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[FalconIA's BLOG]]></copyright>
<item>
<link>http://falconia.org/blog/post//</link>
<title><![CDATA[Dragging Files From Windows to VB.net without API]]></title> 
<author>FalconIA &lt;falcon_ia@hotmail.com&gt;</author>
<category><![CDATA[压制相关]]></category>
<pubDate>Thu, 26 Jan 2006 02:11:39 +0000</pubDate> 
<guid>http://falconia.org/blog/post//</guid> 
<description>
<![CDATA[ 
	<strong>作　者：MSDN<br/>引用自：<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchimpdragdrop.asp" target="_blank">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/ht...</a></strong><br/><br/><strong>Dragging Files</strong><br/><br/>Drag and drop is used pervasively in Windows for moving or copying files. Windows Explorer fully supports drag and drop, and for many users this is the preferred method of working with files. In addition, many users are accustomed to dropping files onto an application to open them — for example, dragging and dropping a .doc file onto Microsoft Word.<br/><br/>In this example drag and drop is used to populate a <strong>ListBox</strong> control with a list of files dragged from Windows Explorer. <br/><br/><strong>To enable drag and drop for a file</strong> <br/><br/>1. Add a <strong>ListBox</strong> control to a form and set its <strong>AllowDrop</strong> property to <strong>True</strong>. <br/>2. Add the following code: <br/><div class="code">Private Sub ListBox1_DragEnter(ByVal sender As Object, ByVal e As _<br/>System.Windows.Forms.DragEventArgs) Handles ListBox1.DragEnter<br/> &nbsp; &nbsp;If e.Data.GetDataPresent(DataFormats.FileDrop) Then<br/> &nbsp; &nbsp; &nbsp; &nbsp;e.Effect = DragDropEffects.All<br/> &nbsp; &nbsp;End If<br/>End Sub<br/><br/>Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As _<br/>System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop<br/> &nbsp; &nbsp;If e.Data.GetDataPresent(DataFormats.FileDrop) Then<br/> &nbsp; &nbsp; &nbsp; &nbsp;Dim MyFiles() As String<br/> &nbsp; &nbsp; &nbsp; &nbsp;Dim i As Integer<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;&#039; Assign the files to an array.<br/> &nbsp; &nbsp; &nbsp; &nbsp;MyFiles = e.Data.GetData(DataFormats.FileDrop)<br/> &nbsp; &nbsp; &nbsp; &nbsp;&#039; Loop through the array and add the files to the list.<br/> &nbsp; &nbsp; &nbsp; &nbsp;For i = 0 To MyFiles.Length - 1<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ListBox1.Items.Add(MyFiles(i))<br/> &nbsp; &nbsp; &nbsp; &nbsp;Next<br/> &nbsp; &nbsp;End If<br/>End Sub</div><br/>You may notice that in the <strong>DragEnter</strong> event the <strong>Effect</strong> is set to <strong>DragDropEffects.All</strong>. Because the files themselves are not actually being moved or copied, it does not really matter which <strong>AllowedEffects</strong> were set by the source, so specifying <strong>All</strong> means that dropping is enabled for any FileDrop.<br/><br/>In the above example the <strong>FileDrop</strong> format contains the full path for each file being dropped. Rather than populating a list, you could just as easily perform other operations on the files — for example, opening them in MDI (multiple-document interface) document windows.<br/>Tags - <a href="http://falconia.org/blog/tags/%25E7%25BC%2596%25E7%25A8%258B/" rel="tag">编程</a> , <a href="http://falconia.org/blog/tags/vb.net/" rel="tag">vb.net</a>
]]>
</description>
</item><item>
<link>http://falconia.org/blog/post//#blogcomment</link>
<title><![CDATA[[评论] Dragging Files From Windows to VB.net without API]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://falconia.org/blog/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>