📄 form1.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "主窗体"
ClientHeight = 2115
ClientLeft = 45
ClientTop = 330
ClientWidth = 4725
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2115
ScaleWidth = 4725
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 3360
Top = 600
End
Begin VB.HScrollBar HScroll2
Height = 255
Left = 960
TabIndex = 5
Top = 1560
Width = 3495
End
Begin VB.HScrollBar HScroll1
Height = 255
Left = 960
TabIndex = 4
Top = 1200
Width = 3495
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 3960
Top = 600
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox Text1
Enabled = 0 'False
Height = 375
Left = 1080
TabIndex = 3
Top = 120
Width = 3375
End
Begin VB.CommandButton Command1
Caption = "打开..."
Height = 375
Left = 120
TabIndex = 2
Top = 120
Width = 975
End
Begin VB.CommandButton Command3
Caption = "停止"
Height = 375
Left = 1320
TabIndex = 1
Top = 600
Width = 975
End
Begin VB.CommandButton Command2
Caption = "播放"
Height = 375
Left = 120
TabIndex = 0
Top = 600
Width = 975
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "结束位置:"
Height = 180
Left = 120
TabIndex = 7
Top = 1597
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "开始位置:"
Height = 180
Left = 120
TabIndex = 6
Top = 1237
Width = 900
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim filename As String
Dim errStr As String * 200
Dim waveForm As Form2
Const MAX_SCROLL_VALUE = 1000
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Sub Form_Load()
Module1.fFileLoaded = False
CommonDialog1.filename = "*.wav"
CommonDialog1.DefaultExt = "wav"
Set waveForm = New Form2
waveForm.Move Me.Left + Me.Width, Me.Top, Me.Width, Me.Height
waveForm.Show 0, Me
HScroll1.Max = MAX_SCROLL_VALUE
HScroll2.Max = MAX_SCROLL_VALUE
HScroll2.Value = MAX_SCROLL_VALUE
End Sub
Private Sub Command1_Click()
CommonDialog1.ShowOpen
filename = CommonDialog1.filename
Text1.Text = filename
LoadFile filename
Module1.drawFrom = 0
Module1.drawTo = Module1.numSamples
HScroll1.Value = 0
HScroll2.Value = MAX_SCROLL_VALUE
waveForm.DrawWaves
End Sub
Private Sub Command2_Click()
If (Module1.fPlaying = False) Then
Play -1
End If
End Sub
Private Sub Command3_Click()
StopPlay
End Sub
Private Sub HScroll1_Change()
If HScroll1.Value >= HScroll2.Value Then
HScroll1.Value = HScroll2.Value - 1
End If
SetPlayRange
End Sub
Private Sub HScroll2_Change()
If HScroll2.Value <= HScroll1.Value Then
HScroll2.Value = HScroll1.Value + 1
End If
SetPlayRange
End Sub
Private Sub SetPlayRange()
Module1.drawFrom = CLng(Module1.numSamples * (HScroll1.Value / MAX_SCROLL_VALUE))
Module1.drawTo = CLng(Module1.numSamples * (HScroll2.Value / MAX_SCROLL_VALUE))
waveForm.DrawWaves
End Sub
Private Sub Timer1_Timer()
If Module1.fPlaying = False Then
Module1.CloseWaveOut
Timer1.Enabled = False
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -