📄 frmmain.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form FrmMain
BorderStyle = 1 'Fixed Single
Caption = "魔剑压缩机"
ClientHeight = 3225
ClientLeft = 150
ClientTop = 540
ClientWidth = 4230
Icon = "FrmMain.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3225
ScaleWidth = 4230
StartUpPosition = 2 '屏幕中心
Begin VB.PictureBox Picture1
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H00FF00FF&
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 480
Left = 2760
ScaleHeight = 480
ScaleWidth = 480
TabIndex = 2
Top = 1680
Visible = 0 'False
Width = 480
End
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 255
Left = 0
TabIndex = 1
Top = 2970
Width = 4230
_ExtentX = 7461
_ExtentY = 450
Style = 1
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin MSComctlLib.ImageList ImageList1
Left = 2760
Top = 600
_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":0ECA
Key = "Directory"
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "FrmMain.frx":0FD1
Key = "UnknowFile"
EndProperty
EndProperty
End
Begin MSComctlLib.TreeView TreeView1
Height = 3015
Left = 0
TabIndex = 0
Top = 0
Width = 4215
_ExtentX = 7435
_ExtentY = 5318
_Version = 393217
LineStyle = 1
Style = 7
Appearance = 1
OLEDragMode = 1
OLEDropMode = 1
End
Begin VB.Menu LoadFile
Caption = "文件(&F)"
Begin VB.Menu NewFile
Caption = "新建压缩文件(&N)"
Shortcut = ^N
End
Begin VB.Menu OpenFile
Caption = "打开压缩文件(&O)"
Shortcut = ^O
End
Begin VB.Menu SaveAs
Caption = "另存为(&S)..."
Shortcut = ^S
End
Begin VB.Menu Depart1
Caption = "-"
End
Begin VB.Menu ExitExe
Caption = "退出(&X)"
End
End
Begin VB.Menu EditFile
Caption = "编辑(&E)"
Begin VB.Menu SaveFileToFolder
Caption = "解压到指定文件夹(&R)"
Shortcut = ^R
End
Begin VB.Menu Depart3
Caption = "-"
End
Begin VB.Menu AddFolderToFile
Caption = "添加目录到压缩文件(&D)"
Shortcut = ^D
End
Begin VB.Menu AddFileToFile
Caption = "添加文件到压缩文件(&F)"
Shortcut = ^F
End
Begin VB.Menu Depart2
Caption = "-"
End
Begin VB.Menu RemoveFileFormFile
Caption = "删除所选文件(&D)"
Shortcut = {DEL}
End
End
Begin VB.Menu Options
Caption = "选项(&N)"
Begin VB.Menu OpenOptions
Caption = "压缩选项(&P)"
Shortcut = ^P
End
End
Begin VB.Menu About
Caption = "关于(&A)"
Begin VB.Menu OpenAbout
Caption = "关于魔剑压缩机(&A)..."
End
End
End
Attribute VB_Name = "FrmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Sub TreeRefresh()
TreeView1.Nodes.Clear
TreeView1.Nodes.Add(, , "DS0", "Root", "Directory").Tag = 0
Set TreeView1.SelectedItem = TreeView1.Nodes.Item(1)
Call GetList(1)
Call ListToTree(TreeView1.Nodes, Picture1, ImageList1)
StatusBar1.SimpleText = "共" & TreeView1.Nodes.Count - 1 & "对象"
End Sub
Private Sub AddFileToFile_Click()
Dim FSO As New Scripting.FileSystemObject
Dim Path As String
Path = ShowOpen("所有文件(*.*)" & Chr$(0) & "*.*")
If FSO.FileExists(Path) Then
Cancel = False
FrmProgress.Show , Me
Me.Enabled = False
Call AddFile(FSO.GetFile(Path), TreeView1.Nodes, TreeView1.SelectedItem, 1)
Me.Enabled = True
TreeRefresh
End If
End Sub
Private Sub AddFolderToFile_Click()
Dim Path As String
Path = ShowDir(Me.hwnd, "添加目录")
If Path <> "" Then
Cancel = False
FrmProgress.Show , Me
Me.Enabled = False
Call AddFolder(Path, TreeView1.Nodes, TreeView1.SelectedItem, 1)
Me.Enabled = True
TreeRefresh
End If
End Sub
Private Sub ExitExe_Click()
End
End Sub
Private Sub Form_Load()
Dim File As String
RePlaceLim = 20
TreeView1.ImageList = ImageList1
EditFile.Enabled = False
File = Command
If Len(File) Then
File = Mid$(File, 2, Len(File) - 2)
If FreeFile <> 1 Then Close #1
Open File For Binary As #1
TreeRefresh
EditFile.Enabled = True
End If
End Sub
Private Sub LoadFile_Click()
SaveAs.Enabled = (FreeFile <> 1)
End Sub
Private Sub NewFile_Click()
On Error GoTo Err
Dim FSO As New Scripting.FileSystemObject
Dim Path As String
Path = ShowSave("压缩文件(*.DSE)" & Chr$(0) & "*.DSE" & Chr$(0) & "自解压文件(*.EXE)" & Chr$(0) & "*.EXE")
If Path <> "" Then
If FSO.FileExists(Path) Then If MsgBox("文件已存在,是否覆盖?", vbOKCancel + vbExclamation) = vbOK Then Kill Path Else Exit Sub
If FreeFile <> 1 Then Close #1
Open Path For Binary As #1
If UCase(Right$(Path, 4)) = ".EXE" Then
Dim a() As Byte
a = LoadResData(101, "CUSTOM")
Put #1, , a
End If
Put #1, , CLng(LOF(1) + 1)
TreeView1.Nodes.Clear
TreeView1.Nodes.Add(, , "DS0", "Root", "Directory").Tag = 0
Set TreeView1.SelectedItem = TreeView1.Nodes.Item(1)
ReDim List(0)
EditFile.Enabled = True
End If
Exit Sub
Err:
MsgBox "Error!"
End Sub
Private Sub OpenAbout_Click()
FrmAbout.Show vbModal
End Sub
Private Sub OpenFile_Click()
Dim File As String, FSO As New FileSystemObject
File = ShowOpen("压缩文件(*.DSE)" & Chr$(0) & "*.DSE" & Chr$(0) & "自解压文件(*.EXE)" & Chr$(0) & "*.EXE")
If FSO.FileExists(File) Then
If FreeFile <> 1 Then Close #1
Open File For Binary As #1
TreeRefresh
EditFile.Enabled = True
End If
End Sub
Private Sub OpenOptions_Click()
FrmOptions.Show vbModal
End Sub
Private Sub RemoveFileFormFile_Click()
Call RemoveFile(TreeView1.SelectedItem, 1)
TreeRefresh
End Sub
Private Sub SaveAs_Click()
On Error GoTo Err
Dim FSO As New Scripting.FileSystemObject
Dim Path As String
Path = ShowSave("压缩文件(*.DSE)" & Chr$(0) & "*.DSE" & Chr$(0) & "自解压文件(*.EXE)" & Chr$(0) & "*.EXE")
If Path <> "" Then
If FSO.FileExists(Path) Then If MsgBox("文件已存在,是否覆盖?", vbOKCancel + vbExclamation) = vbOK Then Kill Path Else Exit Sub
Cancel = False
FrmProgress.Show , Me
Me.Enabled = False
If UCase(Right$(Path, 4)) = ".EXE" Then
Dim a() As Byte
a = LoadResData(101, "CUSTOM")
Put #1, , a
End If
Call ReSave(Path, 1)
If Not Cancel Then
Close #1
Open Path For Binary As #1
End If
Me.Enabled = True
TreeRefresh
End If
Exit Sub
Err:
MsgBox "Error!"
End Sub
Private Sub SaveFileToFolder_Click()
Dim Path As String
Path = ShowDir(Me.hwnd, "目标路径")
If Path <> "" Then
Cancel = False
FrmProgress.Show , Me
Me.Enabled = False
Call ReleaseFile(Path, TreeView1.SelectedItem, 1)
Me.Enabled = True
End If
End Sub
Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton And Not (TreeView1.SelectedItem Is Nothing) Then
PopupMenu EditFile
End If
End Sub
Private Sub TreeView1_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
If UCase(Right$(Data.Files.Item(1), 4)) = ".DSE" Then
If FreeFile <> 1 Then Close #1
Open Data.Files.Item(1) For Binary As #1
TreeRefresh
EditFile.Enabled = True
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -