<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FalconIA&#039;s BLOG &#187; vb.net</title>
	<atom:link href="https://falconia.org/blog/archives/tag/vbnet/feed" rel="self" type="application/rss+xml" />
	<link>https://falconia.org/blog</link>
	<description>FalconIA&#039;s Lazy Blog</description>
	<lastBuildDate>Tue, 02 Dec 2014 01:45:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.38</generator>
	<item>
		<title>VB.NET窗体操作技巧两则</title>
		<link>https://falconia.org/blog/archives/10</link>
		<comments>https://falconia.org/blog/archives/10#comments</comments>
		<pubDate>Thu, 26 Jan 2006 05:18:26 +0000</pubDate>
		<dc:creator><![CDATA[FalconIA]]></dc:creator>
				<category><![CDATA[程序相关]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[编程]]></category>

		<guid isPermaLink="false">http://falconia.no-ip.org/blog/?p=10</guid>
		<description><![CDATA[作　者：刘红军 刘乐坤 引用自：http://www.5ivb.net/Info/89/Info31156/ 目录 一、如何拖动没有边框的窗体？ 二、多个窗体之间互相调用 　　一、如何拖动没有边框的窗体？ 　　这个功能在VB6中，需要借助于API函数才能实现。而在VB.NET中，凭自己的功能就能实现。首先设置窗体的FormBorderStyle属性为none以去掉窗体的边框，然后在窗体上添加一个按钮。窗体中的代码如下： Public Class Form1 　Inherits System.Windows.Forms.Form 　Private mouse_offset As Point 　Private Sub form1_MouseDown(ByVal sender As Object, ByVal e As 　System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown 　　mouse_offset = New Point(e.X, e.Y) 　End Sub Private Sub form1_MouseMove(ByVal Sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove 　&#039;&#039;按住鼠标左右键均可拖动窗体 　If e.Button = MouseButtons.Left Or e.Button [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><b>作　者：刘红军 刘乐坤<br />
引用自：<a href="http://www.5ivb.net/Info/89/Info31156/">http://www.5ivb.net/Info/89/Info31156/</a></b></p>
<p>目录<br />
一、如何拖动没有边框的窗体？<br />
二、多个窗体之间互相调用<br />
<span id="more-10"></span><br />
<hr/>
<p>　　一、如何拖动没有边框的窗体？</p>
<p>　　这个功能在VB6中，需要借助于API函数才能实现。而在VB.NET中，凭自己的功能就能实现。首先设置窗体的FormBorderStyle属性为none以去掉窗体的边框，然后在窗体上添加一个按钮。窗体中的代码如下：</p>
<pre class="brush:vb">
Public Class Form1
　Inherits System.Windows.Forms.Form

　Private mouse_offset As Point
　Private Sub form1_MouseDown(ByVal sender As Object, ByVal e As 　System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
　　mouse_offset = New Point(e.X, e.Y)
　End Sub

Private Sub form1_MouseMove(ByVal Sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
　&#039;&#039;按住鼠标左右键均可拖动窗体
　If e.Button = MouseButtons.Left Or e.Button = MouseButtons.Right Then
　　Dim mousePos As Point = Sender.findform().MousePosition
　　&#039;&#039;获得鼠标偏移量
　　mousePos.Offset(-mouse_offset.X, -mouse_offset.Y)
　　&#039;&#039;设置窗体随鼠标一起移动
　　Sender.findform().Location = mousePos
　End If
End Sub

Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
　&#039;&#039;关闭窗体
　Me.Close()
End Sub
End Class
</pre>
<p>　　 二、多个窗体之间互相调用</p>
<p>　　在VB6中，多个窗体之间可以很方便地互相调用，如：在Form1中，只需要用一条“Form2.Show” 语句就能显示窗体Form2。然而在VB.NET中窗体处理机制发生了很大的变化：在访问窗体之前，你必须进行窗体实例化；如果在项目中有多处代码访问同一窗体，则你必须把它的同一实例指针传递给这些代码，否则新创建的窗体实例就不再是原先的窗体了。</p>
<p>　　下面的代码实现窗体Form1和Form2之间互相调用,Form1为主窗体。Form1上的按钮BtnShowFrm2的标题为“显示Form2”，Form2上的按钮BtnShowFrm1的标题为“显示Form1”。</p>
<p>　　1、Form1中的代码：</p>
<pre class="brush:vb">
Public Class Form1
Inherits System.Windows.Forms.Form
&#039;&#039;创建Form2的一个新的实例
Dim Frm2 As New Form2()

Public Function Instance2(ByVal frm As Form2)
Frm2 = frm
End Function

Private Sub BtnShowFrm2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnShowFrm2.Click
&#039;&#039;以下语句保证在Form2以及其他窗体中访问Form1时，
&#039;&#039;都将得到Form1的同一个窗体实例。
Frm2.Instance(Me)
Frm2.Show()
Me.Hide()
End Sub

End Class
</pre>
<p>　　2、Form2中的代码：</p>
<pre class="brush:vb">
Public Class Form2
　Inherits System.Windows.Forms.Form
　Dim frm1 As Form1
　&#039;&#039;借助一个新增的Instance属性来生成窗体frm1的实例
　Public Function Instance(ByVal frm As Form1)
　　frm1 = frm
　End Function

　Private Sub BtnShowFrm1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 　　　Handles BtnShowFrm1.Click
　　Me.Hide()
　　frm1.Show()
　End Sub

　Private Sub Form2_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles 　MyBase.Closed
　　&#039;&#039;如果Form2被关闭，则设置Form1的按钮BtnShowFrm2不可用。
　　frm1.BtnShowFrm2.Enabled = False
　　frm1.Show()
　End Sub
End Class
</pre>
]]></content:encoded>
			<wfw:commentRss>https://falconia.org/blog/archives/10/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dragging Files From Windows to VB.net without API</title>
		<link>https://falconia.org/blog/archives/8</link>
		<comments>https://falconia.org/blog/archives/8#comments</comments>
		<pubDate>Thu, 26 Jan 2006 04:11:39 +0000</pubDate>
		<dc:creator><![CDATA[FalconIA]]></dc:creator>
				<category><![CDATA[压制相关]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[编程]]></category>

		<guid isPermaLink="false">http://falconia.no-ip.org/blog/?p=8</guid>
		<description><![CDATA[作　者：MSDN 引用自：http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchimpdragdrop.asp Dragging Files 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, [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><b>作　者：MSDN<br />
引用自：<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchimpdragdrop.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchimpdragdrop.asp</a></b></p>
<p><b>Dragging Files</b></p>
<p>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.</p>
<p>In this example drag and drop is used to populate a <b>ListBox</b> control with a list of files dragged from Windows Explorer.<br />
<span id="more-8"></span><br />
<b>To enable drag and drop for a file</b> </p>
<p>1. Add a <b>ListBox</b> control to a form and set its <b>AllowDrop</b> property to <b>True</b>.<br />
2. Add the following code: </p>
<pre class="brush:vb">
Private Sub ListBox1_DragEnter(ByVal sender As Object, ByVal e As _
System.Windows.Forms.DragEventArgs) Handles ListBox1.DragEnter
    If e.Data.GetDataPresent(DataFormats.FileDrop) Then
        e.Effect = DragDropEffects.All
    End If
End Sub

Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As _
System.Windows.Forms.DragEventArgs) Handles ListBox1.DragDrop
    If e.Data.GetDataPresent(DataFormats.FileDrop) Then
        Dim MyFiles() As String
        Dim i As Integer

        &#039; Assign the files to an array.
        MyFiles = e.Data.GetData(DataFormats.FileDrop)
        &#039; Loop through the array and add the files to the list.
        For i = 0 To MyFiles.Length - 1
            ListBox1.Items.Add(MyFiles(i))
        Next
    End If
End Sub
</pre>
<p>You may notice that in the <b>DragEnter</b> event the <b>Effect</b> is set to <b>DragDropEffects.All</b>. Because the files themselves are not actually being moved or copied, it does not really matter which <b>AllowedEffects</b> were set by the source, so specifying <b>All</b> means that dropping is enabled for any FileDrop.</p>
<p>In the above example the <b>FileDrop</b> 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.</p>
]]></content:encoded>
			<wfw:commentRss>https://falconia.org/blog/archives/8/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
