| |

VerySource

 Forgot password?
 Register
Search
Author: blueblues01

Which picture control in VB supports GIF format pictures

[Copy link]

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-29 11:45:01
| Show all posts
Should I import the playback function provided by the moving image playback library quartz.dll (under c:\windows\system32) provided by Windows into VB?
Reply

Use magic Report

0

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-8-29 13:45:01
| Show all posts
[Quote=quote 15th floorjackzengreply:]
Should I import the playback function provided by the moving image playback library quartz.dll (under c:\windows\system32) provided by Windows into VB?
[/Quote]


quartz.dll is a COM component and can be referenced in the VB project. Like Flash animation and Animation animation, you can play it in a loop (always play), or you can play it once.
Reply

Use magic Report

0

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-8-29 14:30:01
| Show all posts
[color=#0000FF][size=18px] Display GIF animation, or GIF picture in the PictureBox control
Get it done in a few lines[/size]:[/color]
[code=VBScript]Option Explicit

'Call the moving image playback type library Quartz.dll, in the c:\windows\system32 directory
Public pMC As FilgraphManager'define pMC as FilgraphManager object
Public pVW As IVideoWindow'define pVW as IVideoWindow object
Public pVP As IMediaPosition
Public pBV As IBasicVideo

'Play GIF animation
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"'Load GIF animation and play it in PictureBox
        Set pVP = pMC
        's = Str(pVP.Duration)
        
        On Error Resume Next
        Set pVW = pMC
        pVW.WindowStyle = CLng(&H6000000)
        pVW.Left = 0: pVW.Top = 0
        
        
        pVW.Owner = Picture1.hWnd
        pVW.MessageDrain = Picture1.hWnd
        pMC.Run
        
        
        Exit Sub
Lhandle:
        MsgBox ("Error loading file!")
End Sub

'Stop playing GIF animation
Private Sub Command2_Click()
        pMC.Stop
End Sub[/code]
Reply

Use magic Report

0

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-8-29 15:00:02
| Show all posts
[code=VBScript]'Changed to limit the image zoom to the size of Picture1
'Display GIF animation (picture) in the PictureBox control, any form control with a handle hwnd can be
Option Explicit

'Call the moving image playback type library Quartz.dll, in the c:\windows\system32 directory
Private pMC As FilgraphManager'define pMC as FilgraphManager object
Private pVW As IVideoWindow'define pVW as IVideoWindow object
'Public pVP As IMediaPosition
'Public pBV As IBasicVideo

'Play GIF animation
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"'Load GIF animation and play it in PictureBox
        'Set pVP = pMC
        's = Str(pVP.Duration)
        
        On Error Resume Next
        Set pVW = pMC
        pVW.WindowStyle = CLng(&H6000000)
        
        'Limit the image in the size of Picture1
        pVW.Left = 0: pVW.Top = 0
        pVW.Width = Picture1.ScaleWidth
        pVW.Height = Picture1.ScaleHeight
        
        pVW.Owner = Picture1.hWnd'Play in Picture1
        pVW.MessageDrain = Picture1.hWnd'This line is very important, it is necessary to define the right-click menu of the image
        pMC.Run'Always play
        
        Exit Sub
Lhandle:
        MsgBox ("Error loading file!")
End Sub

'Stop playing GIF animation
Private Sub Command2_Click()
        pMC.Stop
        Set pVW = Nothing
        Set pMC = Nothing
End Sub

Private Sub Form_Load()
        Me.ScaleMode = 3
        Picture1.ScaleMode = 3
End Sub[/code]
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-29 15:15:01
| Show all posts
deathadam's method is good
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-29 15:30:01
| Show all posts
Thank you, I haven't used quartz.dll. I just tried it and it works. But the biggest question is, can it set the background transparent?

I used a transparent .gif but still cannot be transparent. If it is not transparent, the use value of quartz.dll will be lost...
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-29 15:45:01
| Show all posts
Mark.

Up....
Reply

Use magic Report

0

Threads

7

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-8-29 16:30:01
| Show all posts
[Quote=quote the reply ofak595959on the 21st floor:]
Thank you, I haven't used quartz.dll. I just tried it and it works. But the biggest question is, can it set the background transparent?

I used a transparent .gif but still cannot be transparent. If it is not transparent, the use value of quartz.dll will be lost...
[/Quote]

Can't be transparent, just a method! Of course not as good as the one you did above!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list