frmMain.frm
上传用户:nicktai
上传日期:2010-01-26
资源大小:40k
文件大小:51k
- VERSION 5.00
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
- Object = "{38911DA0-E448-11D0-84A3-00DD01104159}#1.1#0"; "COMCT332.OCX"
- Begin VB.Form frmMain
- Caption = "FtpClient"
- ClientHeight = 5325
- ClientLeft = 165
- ClientTop = 735
- ClientWidth = 8970
- BeginProperty Font
- Name = "Tahoma"
- Size = 8.25
- Charset = 204
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Icon = "frmMain.frx":0000
- LinkTopic = "Form1"
- ScaleHeight = 5325
- ScaleWidth = 8970
- StartUpPosition = 3 'Windows Default
- Begin VB.PictureBox picSplitter
- BackColor = &H8000000D&
- BorderStyle = 0 'None
- FillColor = &H8000000D&
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 204
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 4800
- Left = 6960
- ScaleHeight = 2090.126
- ScaleMode = 0 'User
- ScaleWidth = 780
- TabIndex = 3
- Top = 720
- Visible = 0 'False
- Width = 72
- End
- Begin MSComctlLib.ImageList imlSmall
- Left = 7920
- Top = 720
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 16
- ImageHeight = 16
- MaskColor = 16711935
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 2
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":27A2
- Key = ""
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":2AF6
- Key = ""
- EndProperty
- EndProperty
- End
- Begin MSComctlLib.ImageList imlLarge
- Left = 7080
- Top = 960
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 32
- ImageHeight = 32
- MaskColor = 16711935
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 2
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":2E4A
- Key = ""
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":3A9E
- Key = ""
- EndProperty
- EndProperty
- End
- Begin MSComctlLib.ImageList imlToolbarHot
- Left = 6240
- Top = 1080
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 22
- ImageHeight = 20
- MaskColor = 16711935
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 13
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":46F2
- Key = ""
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":4C96
- Key = ""
- EndProperty
- BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":523A
- Key = ""
- EndProperty
- BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":57DE
- Key = ""
- EndProperty
- BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":5D82
- Key = ""
- EndProperty
- BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":6326
- Key = ""
- EndProperty
- BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":68CA
- Key = ""
- EndProperty
- BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":6E6E
- Key = ""
- EndProperty
- BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":7412
- Key = ""
- EndProperty
- BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":79B6
- Key = ""
- EndProperty
- BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":7F5A
- Key = ""
- EndProperty
- BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":84FE
- Key = ""
- EndProperty
- BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":8AA2
- Key = ""
- EndProperty
- EndProperty
- End
- Begin VB.PictureBox picTitle
- BackColor = &H8000000C&
- BorderStyle = 0 'None
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 204
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 615
- Left = 2160
- ScaleHeight = 615
- ScaleWidth = 4335
- TabIndex = 5
- Top = 720
- Width = 4335
- Begin VB.PictureBox Picture1
- BackColor = &H8000000C&
- BorderStyle = 0 'None
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 204
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 340
- Left = -120
- ScaleHeight = 345
- ScaleWidth = 3255
- TabIndex = 9
- Top = 20
- Width = 3255
- Begin VB.CheckBox Check1
- Appearance = 0 'Flat
- BackColor = &H8000000C&
- Caption = "&Passive Mode"
- ForeColor = &H8000000E&
- Height = 195
- Left = 120
- TabIndex = 12
- Top = 80
- Width = 1335
- End
- Begin VB.OptionButton Option1
- Appearance = 0 'Flat
- BackColor = &H8000000C&
- Caption = "&ASCII"
- ForeColor = &H8000000E&
- Height = 255
- Index = 0
- Left = 1680
- TabIndex = 11
- Top = 80
- Width = 855
- End
- Begin VB.OptionButton Option1
- Appearance = 0 'Flat
- BackColor = &H8000000C&
- Caption = "&Image"
- ForeColor = &H8000000E&
- Height = 255
- Index = 1
- Left = 2520
- TabIndex = 10
- Top = 80
- Value = -1 'True
- Width = 855
- End
- End
- Begin MSComctlLib.ProgressBar ProgressBar1
- Height = 135
- Left = 120
- TabIndex = 6
- Top = 360
- Width = 3495
- _ExtentX = 6165
- _ExtentY = 238
- _Version = 393216
- Appearance = 0
- Min = 1e-4
- Scrolling = 1
- End
- Begin VB.Label Label1
- BackStyle = 0 'Transparent
- Caption = "Label1"
- BeginProperty Font
- Name = "Tahoma"
- Size = 8.25
- Charset = 204
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H8000000E&
- Height = 255
- Left = 120
- TabIndex = 7
- Top = 120
- Width = 3495
- End
- Begin VB.Image imgIcon
- Height = 480
- Left = 3720
- Picture = "frmMain.frx":9046
- Top = 120
- Width = 480
- End
- End
- Begin ComCtl3.CoolBar CoolBar1
- Align = 1 'Align Top
- Height = 450
- Left = 0
- TabIndex = 4
- Top = 0
- Width = 8970
- _ExtentX = 15822
- _ExtentY = 794
- BandCount = 1
- _CBWidth = 8970
- _CBHeight = 450
- _Version = "6.0.8450"
- Child1 = "tbToolBar"
- MinHeight1 = 390
- Width1 = 7935
- NewRow1 = 0 'False
- Begin MSComctlLib.Toolbar tbToolBar
- Height = 390
- Left = 30
- TabIndex = 8
- Top = 30
- Width = 8850
- _ExtentX = 15610
- _ExtentY = 688
- ButtonWidth = 767
- ButtonHeight = 688
- Style = 1
- ImageList = "imlToolbarIcons"
- HotImageList = "imlToolbarHot"
- _Version = 393216
- BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
- NumButtons = 18
- BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "Connect"
- ImageIndex = 1
- EndProperty
- BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Object.ToolTipText = "Connect to ..."
- Style = 3
- EndProperty
- BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "UpLevel"
- ImageIndex = 2
- EndProperty
- BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "Stop"
- Object.ToolTipText = "Stop operation"
- ImageIndex = 3
- EndProperty
- BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "Refresh"
- Object.ToolTipText = "Refresh contents of current directory"
- ImageIndex = 4
- EndProperty
- BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "Download"
- Object.ToolTipText = "Download File..."
- ImageIndex = 5
- EndProperty
- BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "Upload"
- Object.ToolTipText = "Upload File..."
- ImageIndex = 6
- EndProperty
- BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "CreateDirectory"
- Object.ToolTipText = "Create Directory..."
- ImageIndex = 7
- EndProperty
- BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "Delete"
- Object.ToolTipText = "Delete File"
- ImageIndex = 8
- EndProperty
- BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "Rename"
- Object.ToolTipText = "Rename File..."
- ImageIndex = 9
- EndProperty
- BeginProperty Button14 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button15 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "View Large Icons"
- Object.ToolTipText = "View Large Icons"
- ImageIndex = 10
- Style = 2
- EndProperty
- BeginProperty Button16 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "View Small Icons"
- Object.ToolTipText = "View Small Icons"
- ImageIndex = 11
- Style = 2
- EndProperty
- BeginProperty Button17 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "View List"
- Object.ToolTipText = "View List"
- ImageIndex = 12
- Style = 2
- EndProperty
- BeginProperty Button18 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "View Details"
- Object.ToolTipText = "View Details"
- ImageIndex = 13
- Style = 2
- Value = 1
- EndProperty
- EndProperty
- End
- End
- Begin MSComctlLib.ImageList ImageList1
- Left = 5640
- Top = 2280
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 16
- ImageHeight = 16
- MaskColor = 16711935
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 3
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":B7E8
- Key = ""
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":BB3C
- Key = ""
- EndProperty
- BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":BE90
- Key = ""
- EndProperty
- EndProperty
- End
- Begin MSComctlLib.TreeView tvTreeView
- Height = 4800
- Left = 0
- TabIndex = 2
- Top = 705
- Width = 2016
- _ExtentX = 3545
- _ExtentY = 8467
- _Version = 393217
- Indentation = 529
- LineStyle = 1
- PathSeparator = "/"
- Style = 7
- HotTracking = -1 'True
- ImageList = "ImageList1"
- Appearance = 1
- End
- Begin MSComctlLib.ListView lvListView
- Height = 3960
- Left = 2055
- TabIndex = 1
- Top = 1440
- Width = 3210
- _ExtentX = 5662
- _ExtentY = 6985
- View = 3
- LabelEdit = 1
- LabelWrap = -1 'True
- HideSelection = -1 'True
- _Version = 393217
- Icons = "imlLarge"
- SmallIcons = "imlSmall"
- ForeColor = -2147483640
- BackColor = -2147483643
- BorderStyle = 1
- Appearance = 1
- NumItems = 3
- BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
- Text = "File Name"
- Object.Width = 2540
- EndProperty
- BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
- SubItemIndex = 1
- Text = "File Size"
- Object.Width = 2540
- EndProperty
- BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
- SubItemIndex = 2
- Text = "Last Write Date"
- Object.Width = 2540
- EndProperty
- End
- Begin MSComctlLib.StatusBar sbStatusBar
- Align = 2 'Align Bottom
- Height = 270
- Left = 0
- TabIndex = 0
- Top = 5055
- Width = 8970
- _ExtentX = 15822
- _ExtentY = 476
- _Version = 393216
- BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
- NumPanels = 1
- BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
- AutoSize = 1
- Object.Width = 15399
- EndProperty
- EndProperty
- End
- Begin MSComDlg.CommonDialog dlgCommonDialog
- Left = 1740
- Top = 1350
- _ExtentX = 847
- _ExtentY = 847
- _Version = 393216
- End
- Begin MSComctlLib.ImageList imlToolbarIcons
- Left = 1740
- Top = 1350
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 22
- ImageHeight = 20
- MaskColor = 16711935
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 13
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":C1E4
- Key = ""
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":C788
- Key = ""
- EndProperty
- BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":CD2C
- Key = ""
- EndProperty
- BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":D2D0
- Key = ""
- EndProperty
- BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":D874
- Key = ""
- EndProperty
- BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":DE18
- Key = ""
- EndProperty
- BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":E3BC
- Key = ""
- EndProperty
- BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":E960
- Key = ""
- EndProperty
- BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":EF04
- Key = ""
- EndProperty
- BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":F4A8
- Key = ""
- EndProperty
- BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":FA4C
- Key = ""
- EndProperty
- BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":FFF0
- Key = ""
- EndProperty
- BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmMain.frx":10594
- Key = ""
- EndProperty
- EndProperty
- End
- Begin VB.Image imgSplitter
- Height = 4788
- Left = 1965
- MouseIcon = "frmMain.frx":10B38
- MousePointer = 99 'Custom
- Top = 705
- Width = 150
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- Begin VB.Menu mnuConnect
- Caption = "&Connect to ..."
- End
- Begin VB.Menu sep1
- Caption = "-"
- End
- Begin VB.Menu mnuDownload
- Caption = "&Download File ..."
- End
- Begin VB.Menu mnuUpload
- Caption = "&Upload File ..."
- End
- Begin VB.Menu sep2
- Caption = "-"
- End
- Begin VB.Menu mnuFileClose
- Caption = "&Close"
- End
- End
- Begin VB.Menu mnuEdit
- Caption = "&Edit"
- Begin VB.Menu mnuRename
- Caption = "&Rename File ..."
- End
- Begin VB.Menu mnuDelete
- Caption = "&Delete File ..."
- End
- Begin VB.Menu sep3
- Caption = "-"
- End
- Begin VB.Menu mnuCreateDir
- Caption = "&Create Directory ..."
- End
- Begin VB.Menu mnuRemoveDir
- Caption = "&Remove Directory"
- End
- End
- Begin VB.Menu mnuView
- Caption = "&View"
- Begin VB.Menu mnuViewToolbar
- Caption = "&Toolbar"
- Checked = -1 'True
- End
- Begin VB.Menu mnuViewStatusBar
- Caption = "Status &Bar"
- Checked = -1 'True
- End
- Begin VB.Menu sep4
- Caption = "-"
- End
- Begin VB.Menu mnuListViewMode
- Caption = "Lar&ge Icons"
- Index = 0
- End
- Begin VB.Menu mnuListViewMode
- Caption = "S&mall Icons"
- Index = 1
- End
- Begin VB.Menu mnuListViewMode
- Caption = "&List"
- Index = 2
- End
- Begin VB.Menu mnuListViewMode
- Caption = "&Details"
- Index = 3
- End
- Begin VB.Menu sep5
- Caption = "-"
- End
- Begin VB.Menu mnuOptions
- Caption = "&Options..."
- End
- End
- Begin VB.Menu mnuHelp
- Caption = "&Help"
- Begin VB.Menu mnuHelpAbout
- Caption = "&About "
- End
- End
- End
- Attribute VB_Name = "frmMain"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Const NAME_COLUMN = 0
- Const TYPE_COLUMN = 1
- Const SIZE_COLUMN = 2
- Const DATE_COLUMN = 3
- Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
-
- Dim mbMoving As Boolean
- Const sglSplitLimit = 500
- Private m_LastNode As Node
- Private WithEvents m_FtpConnection As CFtpConnection
- Attribute m_FtpConnection.VB_VarHelpID = -1
- Private m_strFile As String
- Private m_lFileSize As Long
- Private Sub Check1_Click()
- If Check1.Value Then
- m_FtpConnection.PassiveMode = True
- Else
- m_FtpConnection.PassiveMode = False
- End If
- End Sub
- Private Sub CoolBar1_HeightChanged(ByVal NewHeight As Single)
- SizeControls picSplitter.Left
- End Sub
- Private Sub Form_Load()
- Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
- Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
- Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
- Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)
-
- Set m_FtpConnection = New CFtpConnection
- m_FtpConnection.Timeout = 180
-
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- Dim i As Integer
- Set m_FtpConnection = Nothing
-
- 'close all sub forms
- For i = Forms.Count - 1 To 1 Step -1
- Unload Forms(i)
- Next
- If Me.WindowState <> vbMinimized Then
- SaveSetting App.Title, "Settings", "MainLeft", Me.Left
- SaveSetting App.Title, "Settings", "MainTop", Me.Top
- SaveSetting App.Title, "Settings", "MainWidth", Me.Width
- SaveSetting App.Title, "Settings", "MainHeight", Me.Height
- End If
- SaveSetting App.Title, "Settings", "ViewMode", lvListView.View
- End Sub
- Private Sub Form_Resize()
- On Error Resume Next
- If Me.Width < 3000 Then Me.Width = 3000
- SizeControls imgSplitter.Left
- End Sub
- Private Sub imgSplitter_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
- With imgSplitter
- picSplitter.Move .Left, .Top, .Width 2, .Height - 20
- End With
- picSplitter.Visible = True
- mbMoving = True
- LockWindowUpdate Me.hwnd
- End Sub
- Private Sub imgSplitter_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
- Dim sglPos As Single
-
- If mbMoving Then
- sglPos = x + imgSplitter.Left
- If sglPos < sglSplitLimit Then
- picSplitter.Left = sglSplitLimit
- ElseIf sglPos > Me.Width - sglSplitLimit Then
- picSplitter.Left = Me.Width - sglSplitLimit
- Else
- picSplitter.Left = sglPos
- End If
- End If
- End Sub
- Private Sub imgSplitter_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
- SizeControls picSplitter.Left
- picSplitter.Visible = False
- mbMoving = False
- End Sub
- Sub SizeControls(x As Single)
-
- On Error Resume Next
- 'set the width
- If x < 1500 Then x = 1500
- If x > (Me.Width - 1500) Then x = Me.Width - 1500
- tvTreeView.Width = x
- imgSplitter.Left = x
- lvListView.Left = x + 40
- picTitle.Left = x + 40
- lvListView.Width = Me.Width - (tvTreeView.Width + 140)
- picTitle.Width = lvListView.Width - 20
- imgIcon.Left = picTitle.Width - imgIcon.Width - 40
- ProgressBar1.Width = picTitle.Width - ProgressBar1.Left - imgIcon.Width - 120
- Picture1.Left = ProgressBar1.Left + (ProgressBar1.Width - Picture1.Width)
- 'set the top
-
- If CoolBar1.Visible Then
- tvTreeView.Top = CoolBar1.Height + 40
- Else
- tvTreeView.Top = 0
- End If
-
- picTitle.Top = tvTreeView.Top
- lvListView.Top = picTitle.Top + picTitle.Height
-
- 'set the height
- If sbStatusBar.Visible Then
- tvTreeView.Height = Me.ScaleHeight - (IIf(CoolBar1.Visible, CoolBar1.Height, 0) + sbStatusBar.Height) - 40
- Else
- tvTreeView.Height = Me.ScaleHeight - IIf(CoolBar1.Visible, CoolBar1.Height, 0) - 40
- End If
- lvListView.Height = tvTreeView.Height - picTitle.Height
- imgSplitter.Top = tvTreeView.Top
- imgSplitter.Height = tvTreeView.Height
-
- LockWindowUpdate 0
-
- End Sub
- Private Sub m_FtpConnection_DownloadProgress(lBytes As Long)
- On Error Resume Next
- sbStatusBar.Panels(1).Text = "Downloading " & m_strFile & " (" & lBytes & " bytes)"
- ProgressBar1.Value = lBytes / (m_lFileSize / 100)
- End Sub
- Private Sub m_FtpConnection_StateChanged(State As FTP_CONNECTION_STATES)
-
- Dim strStatus As String
-
- Select Case State
- Case FTP_CONNECTION_RESOLVING_HOST
- strStatus = "Resolving host..."
- Case FTP_CONNECTION_HOST_RESOLVED
- strStatus = "Host resolved"
- Case FTP_CONNECTION_CONNECTED
- strStatus = "Connected"
- Case FTP_CONNECTION_AUTHENTICATION
- strStatus = "Authentication..."
- Case FTP_USER_LOGGED
- strStatus = "You are logged in. Connection ready."
- Case FTP_ESTABLISHING_DATA_CONNECTION
- strStatus = "Establishing data connection..."
- Case FTP_DATA_CONNECTION_ESTABLISHED
- strStatus = "Data connection established."
- Case FTP_RETRIEVING_DIRECTORY_INFO
- strStatus = "Retrieving directory info..."
- Case FTP_DIRECTORY_INFO_COMPLETED
- strStatus = "Directory listing completed."
- Case State = FTP_TRANSFER_STARTING
- strStatus = "Transfer in progress..."
- Case FTP_TRANSFER_COMLETED
- strStatus = "Transfer completed."
- ProgressBar1.Value = 0.01
- m_lFileSize = 0
- End Select
-
- sbStatusBar.Panels(1).Text = strStatus
-
- End Sub
- Private Sub m_FtpConnection_UploadProgress(lBytes As Long)
- On Error Resume Next
- sbStatusBar.Panels(1).Text = "Uploading " & m_strFile & " (" & lBytes & " bytes)"
- ProgressBar1.Value = lBytes / (m_lFileSize / 100)
- End Sub
- Private Sub mnuConnect_Click()
- Call EstablishConnection
- End Sub
- Private Sub mnuCreateDir_Click()
- Dim strDirName As String
-
- strDirName = InputBox("Enter directory name, please.", "Create new directory")
- If Len(strDirName) > 0 Then
- If m_FtpConnection.CreateDirectory(strDirName) Then
- ListFiles tvTreeView.SelectedItem
- Else
- MsgBox "Can't create new directory." & vbCrLf & vbCrLf & _
- "Server response: " & _
- m_FtpConnection.GetLastServerResponse, , _
- "Can't create directory"
- End If
- End If
-
- End Sub
- Private Sub mnuDelete_Click()
- '
- Dim intRetVal As Integer
- Dim strFileName As String
- '
- On Error GoTo ERROR_HANDLER
- '
- strFileName = tvTreeView.SelectedItem.Key & lvListView.SelectedItem.Text
- '
- intRetVal = MsgBox("Do you really want to delete file " & strFileName & "?", vbYesNoCancel, "Delete file")
- '
- If intRetVal = vbYes Then
- If m_FtpConnection.DeleteFile(strFileName) Then
- ListFiles tvTreeView.SelectedItem
- Else
- MsgBox "Can't delete file." & vbCrLf & vbCrLf & _
- "Server response: " & _
- m_FtpConnection.GetLastServerResponse, , _
- "Can't delete file"
- End If
- End If
- '
- Exit Sub
- '
- ERROR_HANDLER:
- If Err = 91 Then
- MsgBox "Select file to rename, please.", vbInformation, "Rename File"
- Else
- MsgBox "Error occured!" & vbCrLf & "#" & Err.Number & ": " & Err.Description, _
- vbInformation, "Rename File"
- End If
-
- End Sub
- Private Sub mnuDownload_Click()
- Call DownloadFile
- End Sub
- Private Sub mnuEdit_Click()
- With m_FtpConnection
- mnuRename.Enabled = Not .Busy
- mnuRemoveDir.Enabled = Not .Busy
- mnuCreateDir.Enabled = Not .Busy
- mnuDelete.Enabled = Not .Busy
- End With
-
- End Sub
- Private Sub mnuFile_Click()
- With m_FtpConnection
- mnuDownload.Enabled = Not .Busy
- mnuUpload.Enabled = Not .Busy
- End With
-
- End Sub
- Private Sub mnuHelp_Click()
- mnuHelpAbout.Enabled = Not m_FtpConnection.Busy
- End Sub
- Private Sub mnuListViewMode_Click(Index As Integer)
-
- Select Case Index
- Case 0
- lvListView.View = lvwIcon
- Case 1
- lvListView.View = lvwSmallIcon
- Case 2
- lvListView.View = lvwList
- Case 3
- lvListView.View = lvwReport
- End Select
-
- tbToolBar.Buttons(15 + Index).Value = tbrPressed
-
- End Sub
- Private Sub mnuRemoveDir_Click()
- Dim intAnswer As Integer
- Dim CurNode As Node
- Dim i As Integer
- Dim intChildren As Integer
-
- On Error GoTo ERROR_HANDLER
-
- If Not tvTreeView.SelectedItem.Key = tvTreeView.SelectedItem.Root.Key Then
- intAnswer = MsgBox("Do you really want to remove directory: " & tvTreeView.SelectedItem.Text, vbQuestion + vbYesNo, "Remove Directory")
- If intAnswer = vbYes Then
- If m_FtpConnection.RemoveDirectory(tvTreeView.SelectedItem.Key) Then
- Set CurNode = tvTreeView.SelectedItem.Parent
- Set tvTreeView.SelectedItem = CurNode
- '
- 'remove all children nodes of new selected node
- intChildren = CurNode.Children
- For i = 1 To intChildren
- tvTreeView.Nodes.Remove CurNode.Child.Index
- Next i
- '
- ListFiles tvTreeView.SelectedItem
- Else
- MsgBox "Can't remove directory." & vbCrLf & vbCrLf & _
- "Server response: " & _
- m_FtpConnection.GetLastServerResponse, , _
- "Can't remove directory"
- End If
- End If
- End If
-
- Exit Sub
-
- ERROR_HANDLER:
- If Err = 91 Then
- MsgBox "Select file to rename, please.", vbInformation, "Rename File"
- Else
- MsgBox "Error occured!" & vbCrLf & "#" & Err.Number & ": " & Err.Description, _
- vbInformation, "Rename File"
- End If
-
-
- End Sub
- Private Sub mnuRename_Click()
- Dim strFileName As String
- Dim strNewFileName As String
- Dim intAnswer As Integer
- '
- On Error GoTo ERROR_HANDLER
- '
- strFileName = lvListView.SelectedItem.Text
- '
- strNewFileName = InputBox("Enter new file name for " & strFileName, "Rename File")
- '
- If Len(strNewFileName) > 0 Then
- '
- intAnswer = MsgBox("Do you really want to rename file " & strFileName & " to " & strNewFileName & "?", _
- vbYesNo + vbQuestion, "Rename File")
- '
- If intAnswer = vbYes Then
- If m_FtpConnection.RenameFile(strFileName, strNewFileName) Then
- ListFiles tvTreeView.SelectedItem
- Else
- MsgBox "Can't rename file." & vbCrLf & vbCrLf & _
- "Server response: " & _
- m_FtpConnection.GetLastServerResponse, , _
- "Can't rename file"
- End If
- End If
- '
- End If
- '
- Exit Sub
- '
- ERROR_HANDLER:
- If Err = 91 Then
- MsgBox "Select file to rename, please.", vbInformation, "Rename File"
- Else
- MsgBox "Error occured!" & vbCrLf & "#" & Err.Number & ": " & Err.Description, _
- vbInformation, "Rename File"
- End If
-
- End Sub
- Private Sub mnuUpload_Click()
-
- Dim sFile As String
- Dim bFileExists As Boolean
- Dim strFileName As String
- Dim lvItem As ListItem
- Dim intRetVal As Integer
- Dim lStartPoint As Long
-
- On Error Resume Next
-
- With dlgCommonDialog
- .DialogTitle = "Select file to upload"
- .CancelError = True
- .Filter = "All Files (*.*)|*.*"
- .ShowSave
- If Err = 0 Then
- If Len(.FileName) = 0 Then
- Exit Sub
- End If
-
- strFileName = Mid$(.FileName, InStrRev(.FileName, "") + 1)
-
- For Each lvItem In lvListView.ListItems
- If lvItem.Text = strFileName Then
- bFileExists = True
- Exit For
- End If
- Next
-
- m_lFileSize = FileLen(.FileName)
-
- If bFileExists Then
- If m_lFileSize > CLng(lvItem.SubItems(1)) Then
- retVal = MsgBox("File " & strFileName & " already exists!" & vbCrLf & _
- "Size of remote file - " & lvItem.SubItems(1) & " bytes" & vbCrLf & _
- "Size of local file - " & m_lFileSize & " bytes" & vbCrLf & vbCrLf & _
- "Do you want to append lost data to existing file?" & vbclf & vbCrLf & _
- "Note: If you choose No new file will be created.", _
- vbYesNoCancel + vbQuestion, "File already exists")
- If retVal = vbYes Then
- lStartPoint = CLng(lvItem.SubItems(1))
- ElseIf retVal = vbCancel Then
- Exit Sub
- End If
- Else
- retVal = MsgBox("File " & strFileName & " already exists!" & vbCrLf & _
- "Size of remote file - " & lvItem.SubItems(1) & " bytes" & vbCrLf & _
- "Size of local file - " & m_lFileSize & " bytes" & vbCrLf & vbCrLf & _
- "Do you want to cancel upload?" & vbclf & vbCrLf & _
- "Note: If you choose No new file will be created.", _
- vbYesNo + vbQuestion, "File already exists")
- If retVal = vbYes Then
- Exit Sub
- End If
- End If
- End If
-
- m_strFile = strFileName
- If m_FtpConnection.UploadFile(.FileName, strFileName, lStartPoint) Then
- ListFiles tvTreeView.SelectedItem
- Else
- MsgBox "Can't upload file." & vbCrLf & vbCrLf & _
- "Server response: " & m_FtpConnection.GetLastServerResponse, , "Can't upload file"
- End If
- End If
- End With
- End Sub
- Private Sub mnuView_Click()
- With m_FtpConnection
- mnuOptions.Enabled = Not .Busy
- End With
-
- End Sub
- Private Sub Option1_Click(Index As Integer)
- 'm_FtpConnection.TransferMode = IIf(Index = 0, FTP_TYPE_ASCII, FTP_TYPE_IMAGE)
- End Sub
- Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button)
-
- Dim strTemp As String
-
- On Error Resume Next
- Select Case Button.Key
- Case "Connect"
- Call EstablishConnection
- Case "UpLevel"
- Set tvTreeView.SelectedItem = tvTreeView.SelectedItem.Parent
- strTemp = tvTreeView.SelectedItem.FullPath
- strTemp = Mid$(strTemp, InStr(1, strTemp, "/"))
- If m_FtpConnection.SetCurrentDirectory(strTemp) Then
- ListFiles tvTreeView.SelectedItem
- End If
- Case "Stop"
- If Not m_FtpConnection.CloseConnection Then
- If m_FtpConnection.FtpGetLastError = ERROR_FTP_USER_TRANSFER_IN_PROGRESS Then
- Dim intRetVal As Integer
- intRetVal = MsgBox("Data transfer in progress. Do you want to cancel the data transfer?", vbYesNo + vbQuestion)
- If intRetVal = vbYes Then
- m_FtpConnection.CancelTransfer
- End If
- End If
- End If
- Case "Refresh"
- Call RefreshDirectory
- Case "Download"
- mnuDownload_Click
- Case "Upload"
- mnuUpload_Click
- Case "CreateDirectory"
- mnuCreateDir_Click
- Case "Delete"
- mnuDelete_Click
- Case "Rename"
- mnuRename_Click
- Case "View Large Icons"
- lvListView.View = lvwIcon
- Case "View Small Icons"
- lvListView.View = lvwSmallIcon
- Case "View List"
- lvListView.View = lvwList
- Case "View Details"
- lvListView.View = lvwReport
- End Select
- End Sub
- Private Sub mnuHelpAbout_Click()
- frmAbout.Show vbModal
- End Sub
- Private Sub mnuViewStatusBar_Click()
- mnuViewStatusBar.Checked = Not mnuViewStatusBar.Checked
- sbStatusBar.Visible = mnuViewStatusBar.Checked
- SizeControls imgSplitter.Left
- End Sub
- Private Sub mnuViewToolbar_Click()
- mnuViewToolbar.Checked = Not mnuViewToolbar.Checked
- CoolBar1.Visible = mnuViewToolbar.Checked
- SizeControls imgSplitter.Left
- End Sub
- Private Sub mnuFileClose_Click()
- 'unload the form
- Unload Me
- End Sub
- Public Function GetImageNumber(strFileName As String) As Integer
- Dim iPos As Integer
- Dim strExt As String
-
- strExt = Mid$(strFileName, InStrRev(strFileName, ".") + 1)
-
- On Error Resume Next
-
- Select Case LCase(strExt)
- Case "txt", "htm", "html", "lst", "log", "ini", "inf", ""
- GetImageNumber = 1
- Case Else
- GetImageNumber = 2
- End Select
-
- End Function
- Public Function FormatFileSize(lFileSize As Long) As String
-
- On Error GoTo ERROR_HANDLER
-
- If lFileSize >= 1024 Then
- FormatFileSize = Format$(CStr(lFileSize / 1024), "### ### ### KB")
- Else
- FormatFileSize = CStr(lFileSize) & " " & "bytes"
- End If
- Exit Function
-
- ERROR_HANDLER:
- Debug.Print Err.Number & " " & Err.Description
-
- End Function
- Private Sub tvTreeView_DragDrop(Source As Control, x As Single, y As Single)
- If Source = imgSplitter Then
- SizeControls x
- End If
- End Sub
- Private Sub tvTreeView_NodeClick(ByVal Node As MSComctlLib.Node)
-
- With m_FtpConnection
- If .Busy Then
- Set tvTreeView.SelectedItem = m_LastNode
- Exit Sub
- End If
-
- Set m_LastNode = Node
-
- TryAgain:
- If .SetCurrentDirectory(Replace$(Mid$(Node.FullPath, InStr(1, Node.FullPath, "/")), "//", "/")) Then
- ListFiles Node
- Else
- If .FtpGetLastError = ERROR_FTP_WINSOCK_BadState Then
- If .Connect Then
- GoTo TryAgain
- End If
- Else
-
- End If
- End If
-
- End With
-
- End Sub
- Private Sub AddFileToListView(oFtpFile As CFtpFile)
-
- Dim intIcon As Integer
- Dim strFileName As String
-
- strFileName = oFtpFile.FileName
-
- intIcon = GetImageNumber(strFileName)
- Set lvItem = lvListView.ListItems.Add(, strFileName, strFileName, intIcon, intIcon)
- lvItem.SubItems(1) = oFtpFile.FileSize
- lvItem.SubItems(2) = oFtpFile.LastWriteTime
-
- End Sub
- Private Sub DownloadFile()
-
- On Error Resume Next
-
- Dim lStartPoint As Long
- Dim bForceDownload As Boolean
- Dim vTransferMode As FtpTransferModes
-
- With dlgCommonDialog
- 'show to the user the dialog to choose file name to save
- .DialogTitle = "Download file and save as..."
- .CancelError = True
- .Filter = "All Files (*.*)|*.*"
- .FileName = lvListView.SelectedItem.Text
- .ShowSave
- If Err = 0 Then
- If Len(.FileName) = 0 Then
- 'user has clicked Cancel button
- Exit Sub
- End If
- 'get remote file name
- m_strFile = lvListView.SelectedItem.Text
- 'get size of remote file
- m_lFileSize = CLng(lvListView.SelectedItem.SubItems(1))
- '
- 'get transfer mode
- If CBool(Option1(0).Value) Then
- vTransferMode = FTP_ASCII_MODE
- Else
- vTransferMode = FTP_IMAGE_MODE
- End If
-
- If FileExists(.FileName) Then
- '
- Dim strQuestion As String
- Dim intRetVal As Integer
- '
- If FileLen(.FileName) < m_lFileSize Then
- intRetVal = MsgBox("File " & .FileName & " already exists!" & vbCrLf & _
- "Size of remote file - " & m_lFileSize & " bytes" & vbCrLf & _
- "Size of local file - " & FileLen(.FileName) & " bytes" & vbCrLf & vbCrLf & _
- "Do you want to append lost data to existing file?" & vbclf & vbCrLf & _
- "Note: If you choose No new file will be created.", _
- vbYesNoCancel + vbQuestion, "File already exists")
- If intRetVal = vbYes Then
- lStartPoint = FileLen(.FileName)
- ElseIf intRetVal = vbCancel Then
- Exit Sub
- End If
- Else 'FileLen(.FileName) < m_lFileSize
- intRetVal = MsgBox("File " & .FileName & " already exists!" & vbCrLf & _
- "Size of remote file - " & m_lFileSize & " bytes" & vbCrLf & _
- "Size of local file - " & FileLen(.FileName) & " bytes" & vbCrLf & vbCrLf & _
- "Do you want to cancel download?" & vbclf & vbCrLf & _
- "Note: If you choose No new file will be created.", _
- vbYesNo + vbQuestion, "File already exists")
- If intRetVal = vbYes Then
- Exit Sub
- End If
- End If 'FileLen(.FileName) < m_lFileSize
- End If 'FileExists(.FileName)
- 'download file
- TryAgain:
- If Not m_FtpConnection.DownloadFile(m_strFile, .FileName, _
- vTransferMode, lStartPoint) Then
- If m_FtpConnection.FtpGetLastError = ERROR_FTP_WINSOCK_BadState Then
- 'we have lost control connection
- intRetVal = MsgBox("The connection is broken. Do you wish to establish the connect again?", vbQuestion + vbYesNo)
- If intRetVal = vbYes Then
- If m_FtpConnection.Connect Then
- If m_FtpConnection.SetCurrentDirectory(tvTreeView.SelectedItem.FullPath) Then
- GoTo TryAgain
- End If
- Else
- MsgBox "The connection cannot be established.", vbExclamation
- End If
- Else
- Call ResetProgress
- End If
- ElseIf m_FtpConnection.FtpGetLastError = ERROR_FTP_USER_TIMEOUT Then
- intRetVal = MsgBox("Server doesn't response. Do you like to try again?", vbYesNo + vbQuestion)
- If intRetVal = vbYes Then
- GoTo TryAgain
- Else
- Call ResetProgress
- End If
- Else
- MsgBox "Error #" & m_FtpConnection.FtpGetLastError & vbCrLf & vbCrLf & _
- m_FtpConnection.GetFtpErrorDescription, vbExclamation
- End If
- End If
- End If
- End With
- End Sub
- Private Function FileExists(strFileName As String) As Boolean
-
- On Error GoTo ERROR_HANDLER
-
- FileExists = (GetAttr(strFileName) And vbDirectory) = 0
- ERROR_HANDLER:
-
- End Function
- Private Sub RefreshDirectory()
-
- With tvTreeView.SelectedItem
- '
- 'remove all subfolders from treeview
- '
- If .Children > 0 Then
- For i = 1 To .Children
- tvTreeView.Nodes.Remove (.Child.Index)
- Next i
- End If
- '
- lvListView.ListItems.Clear
- '
- ListFiles tvTreeView.SelectedItem
- '
- End With
-
- End Sub
- Private Sub EstablishConnection()
- Dim tvNode As Node
- 'Dim CurNode As Node
- 'create instance of frmConnect form
- Dim f As New frmConnect
- 'show the form
- f.Show vbModal
- 'if OK button was clicked
- If f.Action = comdOK Then
- 'clear the treeview and the listview
- tvTreeView.Nodes.Clear
- lvListView.ListItems.Clear
- '
- With m_FtpConnection
- 'init object properties
- .FtpServer = f.URL
- .UserName = f.UserName
- .Password = f.Password
- .PassiveMode = CBool(Check1.Value)
- 'call Connect method
- If .Connect Then
- Label1 = f.URL
- 'add root node to the treeview
- Set tvNode = tvTreeView.Nodes.Add(, , , .CurrentDirectory, 1)
- tvNode.Key = .CurrentDirectory
- Set tvTreeView.SelectedItem = tvNode
- ListFiles tvNode, True
- End If '.Connect
- End With 'm_FtpConnection
- End If 'f.Action = comdOK
- End Sub
- Private Sub ListFiles(Optional oNode As Node, Optional bRoot As Boolean = False)
- Dim CurNode As Node
- Dim tvNode As Node
- Dim strNewKey As String
-
- On Error Resume Next
- lvListView.ListItems.Clear
- With m_FtpConnection
- .PassiveMode = CBool(Check1.Value)
- 'if connection established
- Dim oFiles As New CFtpFiles
- Dim oFile As CFtpFile
- 'enumerate files in root dir
- If .EnumFiles(oFiles) Then
- Set oFiles = oFiles
- 'if quantity is 1 or more
- If oFiles.Count > 0 Then
- 'walk thru all files in the collection
- For Each oFile In oFiles
- If oFile.IsDirectory Then
- 'if found item is directory
- 'add new child node
- If oNode.Key = oNode.Root.Key Then
- If Not oNode.Key = "/" Then
- strNewKey = oNode.Key & "/" & oFile.FileName & "/"
- Else
- strNewKey = oNode.Key & oFile.FileName & "/"
- End If
- Else
- strNewKey = oNode.Key & oFile.FileName & "/"
- End If
-
- Set tvNode = tvTreeView.Nodes.Add(oNode.Key, tvwChild, strNewKey, oFile.FileName, 2)
- 'tvNode.Key = Mid$(tvNode.FullPath, InStr(1, tvNode.FullPath, "/"))
- tvNode.ExpandedImage = 3
- Else
- 'if found item is file
- 'add new item to the listview
- If tvTreeView.SelectedItem.Key = oNode.Key Then
- AddFileToListView oFile
- End If
- End If 'oFile.IsDirectory
- Next
- End If 'oFiles.Count > 0
- Else
- MsgBox "Error #" & m_FtpConnection.FtpGetLastError & vbCrLf & vbCrLf & _
- m_FtpConnection.GetFtpErrorDescription, vbExclamation
- End If
- End With 'm_FtpConnection
-
- oNode.Expanded = True
- End Sub
- Private Sub ResetProgress()
- ProgressBar1.Value = 0
- sbStatusBar.Panels(1).Text = ""
-
- End Sub