'改了一下,限定图像缩放到Picture1的大小'在PictureBox控件中显示GIF动画(图片),凡有句柄hwnd的窗体控件均可以Option Explicit '调用运动图像播放类型库Quartz.dll,在c:\windows\system32目录下Private pMC As FilgraphManager '定义pMC为FilgraphManager对象Private pVW As IVIDeoWindow '定义pVW为IVIDeoWindow对象'Public pVP As IMediaposition'Public pBV As IBasicVIDeo '播放GIF动画Private Sub Command1_Click() On Error Resume Next Set pMC = New FilgraphManager pMC.Stop 'Set pVP = pMC 'pVP.StopTime = 0 pMC.Renderfile "" On Error GoTo Lhandle pMC.Renderfile "E:\offline.gif" '加载GIF动画,并在PictureBox中播放 'Set pVP = pMC 's = Str(pVP.Duration) On Error Resume Next Set pVW = pMC pVW.windowstyle = CLng(&H6000000) '限定图像在Picture1的大小中 pVW.left = 0: pVW.top = 0 pVW.WIDth = Picture1.ScaleWIDth pVW.Height = Picture1.ScaleHeight pVW.Owner = Picture1.hWnd '在Picture1中播放 pVW.MessageDrain = Picture1.hWnd '此行非常重要,用来定义图像的右键菜单所必须 pMC.Run '一直播放 Exit SubLhandle: MsgBox ("加载文件错误!")End Sub '停止播放GIF动画Private Sub Command2_Click() pMC.Stop Set pVW = nothing Set pMC = nothingEnd Sub Private Sub Form_Load() Me.ScaleMode = 3 Picture1.ScaleMode = 3End Sub总结
以上是内存溢出为你收集整理的VB利用PictureBox控件播放GIF动画全部内容,希望文章能够帮你解决VB利用PictureBox控件播放GIF动画所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)