An Image/Link below is provided (as is) to download presentation
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.Content is provided to you AS IS for your information and personal use only.Download presentation by click this link.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.During download, if you can't get a presentation, the file might be deleted by the publisher.
3. 代码设计 '在代码编辑器窗口的"通用"部分声明π常量 Const Pi = 3.141592653 Private Sub Form_Load() '设置用户的坐标系统 Form1.Scale (-14, 14)-(14, -14) End Sub
3. 代码设计 Private Sub Timer1_Timer() Dim X As Integer Dim Y As Integer Dim Sec, Min, Hr As Integer '计算当前的秒、分、时的数值 Sec = Second(Time) Min = Minute(Time) Hr = Hour(Time) '清空窗体 Form1.Cls
3. 代码设计 '绘制秒针,其中用到的数字9起放大作用 Form1.DrawWidth = 2 '设置线条的宽度 X = 9 * Cos((Sec - 15) * Pi / 30) '计算线条另一端点的x坐标 Y = 9 * Sin(-(Sec - 15) * Pi / 30) '计算线条另一端点的y坐标 Form1.Line (0, 0)-(X, Y), vbRed '画一条红线表示秒针 '绘制分针,其中用到的数字8起放大作用 Form1.DrawWidth = 3 '设置线条的宽度 X = 8 * Cos((Min - 15) * Pi / 30) '计算线条另一端点的x坐标 Y = 8 * Sin(-(Min - 15) * Pi / 30) '计算线条另一端点的y坐标
3. 代码设计 '绘制时针,其中用到的数字6起放大作用 Hr = Hr + Min / 60 Form1.DrawWidth = 5 '设置线条的宽度 X = 6 * Cos((Hr - 3) * Pi / 6) '计算线条另一端点的x坐标 Y = 6 * Sin(-(Hr - 3) * Pi / 6) '计算线条另一端点的y坐标 Form1.Line (0, 0)-(X, Y) '画线表示分针 End Sub [演示]
2. 界面设计 (1)创建一个“标准EXE”工程,选中“工程”菜单中的“部件”选项,在弹出的“部件”对话框中选择“Microsoft Multimedia Control”, “Microsoft Common Dialog Control 6.0”和 “Microsoft Windows Common Control 6.0”,将CommonDialog控件、MMControl控件和Slider控件添加到根据箱中。 (2)窗体添加“命令”按钮和“关闭按钮”。 (3)窗体添加CommonDialog 控件、Picture控件、MMControl控件和Slider控件。
3. 代码设计 (1)窗体Load事件代码 Private Sub Form_Load() '将Picture1设置为视频回放的界面 MMControl1.hWndDisplay = Picture1.hWnd End Sub
3. 代码设计 '如果打开的文件是*.dat格式,则执行下面的语句 ElseIf CommonDialog1.FilterIndex = 1 Then '设置多媒体设备类型为WaveAudio MMControl1.DeviceType = "MpegVideo" '设置打开的文件为通用对话框中选择的文件 MMControl1.FileName = CommonDialog1.FileName '打开文件 MMControl1.Command = "Open" MMControl1.Command = "Play" '设置Slider控件的最小值 Slider1.Min = 0 '设置Slider的最大值为文件的长度 Slider1.Max = MMControl1.Length End If End Sub
3. 代码设计 (3)MMControl1控件的StatusUpdate事件代码 Private Sub MMControl1_StatusUpdate() '设置Sider1控件的滑杆位置 With MMControl1 If DeviceID <> 0 Then If Slider1.Value <> MMControl1.Position Then Slider1.Value = MMControl1.Position End If End With End Sub
3. 代码设计 (4)Slider控件的Scroll事件代码 Private Sub Slider_Scroll() '通过Slider选择文件的播放位置 MMControl1.To Slider.Value MMControl1.Command = "Seek" MMControl1.Command = "Play" End Sub
3. 代码设计 '(5)窗体的Unload事件代码 Private Sub Form_Unload(Cancel As Integer) '关闭多媒体设备 MMControl1.Command = "Stop" MMControl1.Command = "Close" End Sub '(6)"关闭"按钮的Click事件代码 Private Sub Command2_Click() '退出应用程序 End End Sub