Jump to content

animated GIFs


 Share

Recommended Posts

This:

<body bgcolor="ECE9D8" marginheight="0" topmargin="0" vspace="0" marginwidth="0" leftmargin="0" hspace="0" style="margin:0; padding:0; overflow:hidden;"><img src="animated pic.gif" /></body>

would work for transparent gifs and make the margens 0... Just replace "animated pic.gif" with the picture.

To get the page onto a GUI use something like in this example:

Opt("ExpandVarStrings", 1)
$oIE = ObjCreate("Shell.Explorer.2")
GUICreate( "Embedded Web control Test", 640, 580, (@DesktopWidth-640)/2, (@DesktopHeight-580)/2)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 640, 580)
$oIE.navigate("@ScriptDir@\animated.html")
GUISetState()
While GUIGetMsg() <> -3
WEnd
Basically ObjCreate() then GUICtrlCreateObj() to the size of the pic. Then navigate to the html file.

[edit]

O ya... Release the object at the end:

$oIE = 0

[edit2]

Tell me if it works as I don't currently have an animated pic to test it on.

[edit3]

Got rid of the verticle scrollbar.

Edited by gamerman2360
Link to comment
Share on other sites

If you like UDFs to do the work for you:

; Made by Gamerman2360
Func GUICtrlCreateInetPic($filename, $left, $top, $width, $height)
    $oIE = ObjCreate("Shell.Explorer.2")
    $ctrlID = GUICtrlCreateObj($oIE, $left, $top, $width, $height)
    $oIE.navigate("about:blank")
    $oIE.document.write('<base href="' & @WorkingDir & '">' & _
    '<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">' & _
    '<img src="' & $filename & '" /></body>')
    Dim $return[2] = [$ctrlID, $oIE]
    Return $return
EndFunc
Make sure you have the beta.

Edit: Updated since I learned more about the IE object.

Edited by gamerman2360
Link to comment
Share on other sites

Works perfect. Thanks. Note - requires beta.

#include <GuiConstants.au3>
HotKeySet("{ESC}", "Terminate")
Func Terminate()
    $oIE = 0
    Exit 
EndFunc

Opt("ExpandVarStrings", 1)
$oIE = ObjCreate("Shell.Explorer.2")
GUICreate( "Embedded Web control Test", 640, 580, (@DesktopWidth-640)/2, (@DesktopHeight-580)/2)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 640, 580)
$oIE.navigate("@ScriptDir@\animated.html")
GUISetState()
While GUIGetMsg() <> -3
WEnd

animated.html file

<body bgcolor="ECE9D8" marginheight="0" topmargin="0" vspace="0" marginwidth="0" leftmargin="0" hspace="0" style="margin:0; padding:0; overflow-x:hidden; overflow-y:hidden;"><img src="animated gif.gif" /></body>
Edited by peter1234
Link to comment
Share on other sites

There are two solutions more gif graphics related, one is to use Cwebpage library and wrapup some html code and last there is the freeware gif activex component - download able from my site with a funny example - checkit out...

CWebpage library animated gif example:

http://www.sitecenter.dk/latenight/nss-fol...e/Au3Update.exe

Gif component funny example from site: download both files

http://www.sitecenter.dk/latenight/nss-folder/download

Both examples come with source code...

kjactive :P

Edited by kjactive
Link to comment
Share on other sites

@gamerman2360:

OK. Got UDF working. FileWrite line needs to have all of HTML in one line.

#include <GuiConstants.au3>
HotKeySet("{ESC}", "Terminate")
Func Terminate()
    $oIE = 0
    Exit 
EndFunc

Func GUICtrlCreateAnimatedPic($filename, $left, $top, $width, $height)
    $ExpandVarStrings = Opt("ExpandVarStrings", 1)
    If FileExists("@TempDir@\temp131.html") Then FileDelete("@TempDir@\temp131.html")
    If FileExists("@TempDir@\temp132.gif") Then FileDelete("@TempDir@\temp132.gif")
    FileWrite("@TempDir@\temp131.html", '<body bgcolor="ECE9D8" marginheight="0" topmargin="0" vspace="0" marginwidth="0" leftmargin="0" hspace="0" style="margin:0; padding:0; overflow:hidden;"><img src="@TempDir@\temp132.gif" /></body>')
    FileCopy($filename, "@TempDir@\temp132.gif")
    $oIE = ObjCreate("Shell.Explorer.2")
    GUICtrlCreateObj($oIE, $left, $top, $width, $height)
    $oIE.navigate("@TempDir@\temp131.html")
    Opt("ExpandVarStrings", $ExpandVarStrings)
EndFunc

GuiCreate("",@DesktopWidth,@Desktopheight,-1,-1)
GUISetState () 

$filename = "C:\animated_gif.gif"
$width = 200
$height = 150
$left = @DesktopWidth/2 - $width/2
$top = @Desktopheight/2 - $height/2
GUICtrlCreateAnimatedPic($filename, $left, $top, $width, $height)

sleep (10000)
$oIE = 0
EXIT
Edited by peter1234
Link to comment
Share on other sites

I wonder why making it to 2 lines made it not work.

[edit]

Ah, I see. I tested this:

Opt("ExpandVarStrings", 1)
    MsgBox(0, "Test", '<body bgcolor="ECE9D8" marginheight="0" topmargin="0" vspace="0" marginwidth="0" ' &_
    'leftmargin="0" hspace="0" style="margin:0; padding:0; overflow:hidden;"><img src="@TempDir@\temp132.gif" /></body>')
And I guess "&_" causes an error. Changed it to "& _" in the UDF. Also changed it so it returns the control ID.

[edit2]

Actually I couldn't decide which to have it return between the ID and the object because you can't really do much with GUICtrlCreateObj()s ID so I made it into an array and returned both.

Edited by gamerman2360
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...