Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim LineY&, ColoumX& LineY& = Round((Y - 13) / 5) ‘行圆整 ColoumX& = Round((X - 30) / 16) ‘列圆整 If Not (ColoumX& > 0 And LineY& > 0) Then Exit Sub End If If Music(LineY&, ColoumX& + HScroll1.Value) = 0 Then Music(LineY&, ColoumX& + HScroll1.Value) = Selection ‘ 记录音符 End If DisplayNotes ‘在客户区显示当前音符 End Sub 当程序运行时,首先通过主窗体的Form Load事件在Picture1的客户区绘出五线谱的五条平行的水平线,作曲者便可以根据不同的音高在相应位置插入音符。插入音符的过程是通过上面的DisplayNotes函数来实现的,利用Windows系统的API(应用程序接口)函数Bitblt所具有的内存数据传送的功能将Picture2中位图的一部分提取出来并按照一定的变换后插入到Picture1的客户区制定位置,主要代码如下:
Select Case ID Case 1 BitBlt Picture1.hdc, X& - 7, Y& - 18, 20, 30, Picture2.hdc, 66, 0, SRCAND Case 2 BitBlt Picture1.hdc, X& - 5, Y& - 18, 20, 30, Picture2.hdc, 0, 0, SRCAND …