📄 tg_filecomp.ctl
字号:
VERSION 5.00
Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL"
Begin VB.UserControl tg_FileComp
BackColor = &H00FFFFFF&
ClientHeight = 4455
ClientLeft = 0
ClientTop = 0
ClientWidth = 5490
LockControls = -1 'True
ScaleHeight = 4455
ScaleWidth = 5490
Begin VB.CommandButton C
BackColor = &H00FFFFFF&
Caption = "文件2"
Height = 255
Index = 2
Left = 330
TabIndex = 4
Top = 3675
Width = 1575
End
Begin VB.CommandButton C
BackColor = &H00FFFFFF&
Caption = "文件1"
Height = 255
Index = 1
Left = 345
TabIndex = 3
Top = 3225
Width = 1560
End
Begin VB.PictureBox p
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 1830
Index = 2
Left = 1005
ScaleHeight = 1800
ScaleWidth = 2940
TabIndex = 1
Top = 915
Width = 2970
End
Begin VB.PictureBox p
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 1950
Index = 1
Left = 240
ScaleHeight = 1920
ScaleWidth = 3030
TabIndex = 0
Top = 255
Width = 3060
End
Begin MSForms.ScrollBar v
Height = 3030
Left = 4635
TabIndex = 2
Top = 495
Width = 255
ForeColor = 0
VariousPropertyBits= 25
Size = "450;5345"
PrevEnabled = 0
NextEnabled = 0
End
End
Attribute VB_Name = "tg_FileComp"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Dim meCol As Long
Dim meRow As Long
Dim fn1 As Byte
Dim fn2 As Byte
Dim buf1() As Byte
Dim buf2() As Byte
Dim FileSize As Long
Private Declare Sub InitCommonControls Lib "comctl32.dll" ()
Private Sub C_GotFocus(Index As Integer)
p(1).SetFocus
End Sub
Private Sub UserControl_Initialize()
InitCommonControls
C(1).Top = 0
C(2).Top = 0
C(1).Left = 0
p(1).Top = C(1).Height - 15
p(2).Top = C(1).Height - 15
p(1).Left = 0
v.Top = 0
End Sub
Private Sub UserControl_Resize()
Dim meWidth As Long
meWidth = UserControl.Width - v.Width - 40
p(1).Width = meWidth / 2
p(2).Width = meWidth / 2
C(1).Width = p(1).Width
C(2).Width = p(2).Width
p(2).Left = meWidth / 2 + 40
C(2).Left = p(2).Left
v.Left = meWidth + 40
v.Height = UserControl.Height
p(1).Height = v.Height - C(1).Height
p(2).Height = v.Height - C(1).Height
meCol = p(1).Height \ p(1).TextHeight("A")
meRow = p(1).Width \ p(1).TextWidth("A") \ 3
End Sub
Private Sub LoadFile()
Dim i As Long
Dim n As Double
Dim tmp As String
p(1).Cls
p(2).Cls
p(1).Print " ";
p(2).Print " ";
n = v.value
n = (n - 1) * meRow + 1
If FileSize - n < meRow * meCol Then
ReDim buf1(1 To FileSize - n)
ReDim buf2(1 To FileSize - n)
Else
ReDim buf1(1 To meRow * meCol)
ReDim buf2(1 To meRow * meCol)
End If
Get #fn1, n, buf1()
Get #fn2, n, buf2()
For i = 1 To UBound(buf1)
If buf1(i) <> buf2(i) Then
p(1).ForeColor = &HFF
p(2).ForeColor = &HFF
Else
p(1).ForeColor = &H0
p(2).ForeColor = &H0
End If
tmp = Hex(buf1(i))
tmp = IIf(Len(tmp) = 1, "0" & tmp & " ", tmp & " ")
p(1).Print tmp;
tmp = Hex(buf2(i))
tmp = IIf(Len(tmp) = 1, "0" & tmp & " ", tmp & " ")
p(2).Print tmp;
If i Mod meRow = 0 Then
p(1).Print
p(2).Print
p(1).Print " ";
p(2).Print " ";
End If
Next i
End Sub
Private Sub V_Change()
LoadFile
End Sub
Private Sub V_Scroll()
LoadFile
End Sub
Public Function Initme(FileName1 As String, FileName2 As String)
fn1 = FreeFile
Open FileName1 For Binary As #fn1
fn2 = FreeFile
Open FileName2 For Binary As #fn2
If LOF(fn1) > LOF(fn2) Then
FileSize = LOF(fn2)
Else
FileSize = LOF(fn1)
End If
v.Min = 1
v.Max = FileSize \ meRow + IIf(FileSize Mod meRow = 0, 0, 1) - meCol + 1
If v.Max <= 0 Then
v.Enabled = False
Else
v.Enabled = True
End If
LoadFile
End Function
Public Function Endme()
Close fn1
Close fn2
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -