?? form1.vb
字號:
Me.Command2.BackColor = System.Drawing.SystemColors.Control
Me.Command2.Cursor = System.Windows.Forms.Cursors.Default
Me.Command2.ForeColor = System.Drawing.SystemColors.ControlText
Me.Command2.Location = New System.Drawing.Point(360, 64)
Me.Command2.Name = "Command2"
Me.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Command2.Size = New System.Drawing.Size(74, 25)
Me.Command2.TabIndex = 2
Me.Command2.Text = "中斷連接"
'
'ListView1
'
Me.ListView1.Location = New System.Drawing.Point(0, 136)
Me.ListView1.Name = "ListView1"
Me.ListView1.OcxState = CType(resources.GetObject("ListView1.OcxState"), System.Windows.Forms.AxHost.State)
Me.ListView1.Size = New System.Drawing.Size(321, 145)
Me.ListView1.TabIndex = 1
'
'ImageList1
'
Me.ImageList1.Enabled = True
Me.ImageList1.Location = New System.Drawing.Point(368, 144)
Me.ImageList1.Name = "ImageList1"
Me.ImageList1.OcxState = CType(resources.GetObject("ImageList1.OcxState"), System.Windows.Forms.AxHost.State)
Me.ImageList1.Size = New System.Drawing.Size(38, 38)
Me.ImageList1.TabIndex = 5
'
'Command1
'
Me.Command1.BackColor = System.Drawing.SystemColors.Control
Me.Command1.Cursor = System.Windows.Forms.Cursors.Default
Me.Command1.ForeColor = System.Drawing.SystemColors.ControlText
Me.Command1.Location = New System.Drawing.Point(360, 32)
Me.Command1.Name = "Command1"
Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Command1.Size = New System.Drawing.Size(74, 25)
Me.Command1.TabIndex = 0
Me.Command1.Text = "連接"
'
'Timer1
'
Me.Timer1.Interval = 500
'
'Inet1
'
Me.Inet1.Enabled = True
Me.Inet1.Location = New System.Drawing.Point(368, 208)
Me.Inet1.Name = "Inet1"
Me.Inet1.OcxState = CType(resources.GetObject("Inet1.OcxState"), System.Windows.Forms.AxHost.State)
Me.Inet1.Size = New System.Drawing.Size(38, 38)
Me.Inet1.TabIndex = 6
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.BackColor = System.Drawing.SystemColors.Control
Me.ClientSize = New System.Drawing.Size(439, 292)
Me.Controls.Add(Me.Frame1)
Me.Controls.Add(Me.Command3)
Me.Controls.Add(Me.Command2)
Me.Controls.Add(Me.ListView1)
Me.Controls.Add(Me.ImageList1)
Me.Controls.Add(Me.Command1)
Me.Controls.Add(Me.Inet1)
Me.Cursor = System.Windows.Forms.Cursors.Default
Me.Location = New System.Drawing.Point(4, 24)
Me.Name = "Form1"
Me.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Text = "連接FTP"
Me.Frame1.ResumeLayout(False)
CType(Me.ListView1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.ImageList1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.Inet1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Dim strDirectory As String
Dim InetState As String
Private Sub Check1_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Check1.CheckStateChanged
If Check1.CheckState = 1 Then
Text2.Text = "anonymous"
Text3.Text = "aldl@263.net"
Else
Text2.Text = ""
Text3.Text = ""
End If
End Sub
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click
Dim i As Short
Dim temp, strurl As String
On Error GoTo Handle_Renamed
strurl = Text1.Text
Inet1.UserName = Text2.Text
Inet1.Password = Text3.Text
For i = 1 To 4 '處理輸入的URL
temp = Mid(strurl, i, 1)
If Asc(temp) <= Asc("z") And Asc(temp) >= Asc("a") Then
strurl = VB.Left(strurl, i - 1) & StrConv(temp, VbStrConv.UpperCase) & VB.Right(strurl, Len(strurl) - i)
End If
Next i
If VB.Left(strurl, 6) = "FTP://" Then
Inet1.Execute(strurl)
Else
Inet1.Execute("ftp://" & strurl)
End If
Timer1.Enabled = True
Handle_Renamed:
End Sub
Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
Inet1.Cancel()
ListView1.ListItems.Clear()
End Sub
Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command3.Click
End
End Sub
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
ListView1.View = 0 '使用大圖標格式
End Sub
Private Sub Inet1_StateChanged(ByVal eventSender As System.Object, ByVal eventArgs As AxInetCtlsObjects.DInetEvents_StateChangedEvent) Handles Inet1.StateChanged
InetState = CStr(eventArgs.state)
System.Windows.Forms.Application.DoEvents()
End Sub
Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
System.Windows.Forms.Application.DoEvents()
'監視連接狀態
Dim iFile As Short
Dim strBuff As String
If CDbl(InetState) = 12 Then
Timer1.Enabled = False
strBuff = Inet1.GetChunk(1024)
iFile = FreeFile()
'Len1 = Len(strBuff)
FillList((strBuff))
End If
End Sub
Private Sub FillList(ByRef dirName As String)
Dim aa As Object
'處理返回的目錄信息
Dim i2, i, i1, j As Short
Dim nodexx As MSComctlLib.ListItem
Dim ss, filen As String
Dim TL As Boolean
ListView1.ListItems.Clear()
i2 = 0
1:
i1 = Len(dirName)
TL = False
For i = 1 To i1
ss = Mid(dirName, i, 1)
aa = Asc(ss)
If aa = 13 Then
filen = Mid(dirName, 1, i - 1)
If Len(filen) >= 1 Then
i2 = i2 + 1
For j = 1 To Len(filen)
If Mid(filen, j, 1) = "/" Then
TL = True
filen = Mid(filen, 1, j - 1)
Exit For
End If
Next j
If TL Then
nodexx = ListView1.ListItems.Add(i2, filen, filen, 1)
Else
nodexx = ListView1.ListItems.Add(i2, filen, filen, 2)
End If
ListView1.View = 0
dirName = Mid(dirName, i + 2, i1 - i - 2)
GoTo 1
End If
End If
Next i
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -