Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Show animated Gifs in your GUI


  • Please log in to reply
64 replies to this topic
PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
This has been often asked, here it is, at least!
Thanks to majkinetor which found a gold mine of custom Windows controls written in assembly language: they are small, they are fast, they are mean!

In the forum pointed out in RaGrid - Extreme Grid control, I found an AniGIF control and I tried to write a wrapper for it. Here is the result.

Control_AniGif.ahk

I used four Gif files for the demo, links below. The first two were "stolen" to deviantART, credit goes to them and their creators. The last one is static, on purpose.
<!-- m -->http://autohotkey.ne...ages/pacman.gif<!-- m -->
<!-- m -->http://autohotkey.ne...es/teleport.gif<!-- m -->
<!-- m -->http://autohotkey.ne...Flag_France.gif<!-- m -->
<!-- m -->http://autohotkey.ne...mages/Earth.gif<!-- m -->
[EDIT] Changed the script to automatically download them if not in the script dir.

And of course, you need the DLL, which can be found at the WinAsm site: <!-- m -->http://www.winasm.ne... ... w&iden=150<!-- m -->
[EDIT] The above link is outdated but it is freely available, so I leave it. You have to register to the WinAsm forum to get the latest file, so I uploaded the DLL to my AutoHotkey.net account (automatically downloaded by the script, too). <!-- m -->http://autohotkey.ne...iLho/AniGIF.dll<!-- m -->

The last problem is that the displayed Gifs lack transparency. I don't know if I must add a style to change this, or if that's a limitation of the library.

[EDIT] I found out, I must not take the public zip file but I had to register to the forum to get the latest file from the topic... This one adds the WAGM_SETBKCOLOR and transparency!
For your convenience, I provide the DLL, hoping the author doesn't mind. I copy his copyright in the source, since I have no About box...

;|AniGIF is a copyright of Antonis Kyprianou. |
;| |
;|You can use AniGIF for NON commercial purposes provided you |
;|have the following information on your application's about box: |
;|AniGIF control is copyright of Antonis Kyprianou (<!-- m -->http://www.winasm.net<!-- m -->)|
;| |
;|You need my WRITTEN permission to use AniGIF in commercial applications |


[EDIT] Better encapsulation (everything in functions), styles given as strings, hyperlink working in the demo.

// File/Project history:
1.03.000 -- 2007/05/17 (PL) -- Total encapsulation.
1.02.000 -- 2007/05/16 (PL) -- Changed functions names (thanks majkinetor), added more wrappers, freed correctly DLL.
1.01.000 -- 2007/05/16 (PL) -- Update to 1.0.4.0 with WAGM_SETBKCOLOR.
1.00.000 -- 2007/05/16 (PL) -- Creation.


Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
Its not lack of library. Examples clearly show that.
Posted Image

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Great! Many thanks PhiLho, :D

.. and also for Mr.Antonis Kyprianou for this wonderful DLL.

:)

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
I don't know why you didn't follow API design I used. I don't like how you wrapped it, as I have to copy/paste around instad just to include AniGif.

What acctually adds the damn things just looking from names ?
GuiAddAniGif
GuiControlAddAniGif

The principle I planned to used for all controls that are to be wrapped is

CtrlName_Add( ) - to add to the gui, returns handle
CtrlName_MsgName

where CtrlName can eventualy be shorthand and "GIF" word stripped off.

So, the names should be:
AniGif_Add()
AniGif_Zoom()
AniGif_LoadFromFile()
AniGif_SetHyperLink()
AniGif_Unload()
saved in the file AniGif.ahk

Also, use Antonis desires to use <!-- m -->http://www.winasm.net<!-- m --> link to point to his location. Its Ok to include dll in your archive.

2 Skan
LOL, today is like birthday, isn't it :D
Posted Image

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

2 Skan
LOL, today is like birthday, isn't it :D


Sure it is!
Life is Beautiful :D

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Updated script, uploaded latest DLL, which is downloaded automatically.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

I don't know why you didn't follow API design I used. I don't like how you wrapped it, as I have to copy/paste around instad just to include AniGif.

I didn't knew you established an authoritative norm for DLL control wrapping...
You shouldn't have to copy/paste around, the file is designed to be included on top of the script that uses the control.
I used a similar scheme for CreateWindow_AVI.ahk and CreateWindow_IPA.ahk
The idea was to provide functions names similar to the AHK GUI commands...

Now, I must admit I am not super-happy with these names (slightly obfuscated indeed), and your naming scheme isn't so bad... :-)
Someday I might change them.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006

I didn't knew you established an authoritative norm for DLL control wrapping...


You shouldn't have to copy/paste around, the file is designed to be included on top of the script that uses the control.


U are too old for this PhiLho. :!:
Posted Image

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

U are too old for this PhiLho. :!:

:?:

BTW, I would use AniGif_CreateControl instead of AniGif_Add, as the later scheme is more likely to clash with some message name in some control.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006

as the later scheme is more likely to clash with some message name in some control.

Not at all. Its not by the MS Standard to use message name like ADD. Each control has unique prefix, that is clearly visible if you snoop around the masm forum or MSDN.

You shouldn't have to copy/paste around, the file is designed to be included on top of the script that uses the control.

Why should I include your presentation GUI ?

I didn't knew you established an authoritative norm for DLL control wrapping...

Open your eyes. Not just me. Sean didn't had the problem to switch in one word. Contrary to that U choosed to spread disorganisation instead we all stick to the same standard.

Now, I must admit I am not super-happy with these names (slightly obfuscated indeed)

Slightly ?
Question for million dolars. Which function does what ?

GuiAddAniGif
GuiControlAddAniGif

I used a similar scheme for CreateWindow_AVI.ahk and CreateWindow_IPA.ahk

So you had bad choice more then once.

:?:

Means you don't listen.

2Skan
Your happines makes me happy :)
Posted Image

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

as the later scheme is more likely to clash with some message name in some control.

Not at all. Its not by the MS Standard to use message name like ADD. Each control has unique prefix, that is clearly visible if you snoop around the masm forum or MSDN.

You removed these prefixes... As I wrote, one can find a WAGM_ADD message or similar.

You shouldn't have to copy/paste around, the file is designed to be included on top of the script that uses the control.

Why should I include your presentation GUI ?

Indeed, but:
1) It is very easy to remove it. That's not a compiled program;
2) It isn't that long.

I didn't knew you established an authoritative norm for DLL control wrapping...

Open your eyes. Not just me. Sean didn't had the problem to switch in one word. Contrary to that U choosed to spread disorganisation instead we all stick to the same standard.

I didn't saw where this standard was published...
As I wrote, it isn't a bad standard, but don't reproach me not to download all the scripts you wrote and to study them closely.

Means you don't listen.

No, means you are unclear.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

freakkk
  • Members
  • 182 posts
  • Last active: Dec 16 2014 06:23 PM
  • Joined: 29 Jul 2005
CreateWindow_AniGif_Exit:

; Deactivated as it crashes my script!?

	If (hAniGifModule != "" and hAniGifModule != 0)

		DllCall("FreeLibrary", "UInt", hAniGifModule)

ExitApp
I tried using
DllCall("FreeLibrary", "UInt *", hAniGifModule)

..and it seems okay.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

DllCall("FreeLibrary", "UInt *", hAniGifModule)

..and it seems okay.

Uh? It might work but it makes no sense... Oh well, I believe the DLL is unloaded when the script ends, anyway.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

freakkk
  • Members
  • 182 posts
  • Last active: Dec 16 2014 06:23 PM
  • Joined: 29 Jul 2005
I believe it is too. What really didn't make sense to me was the Str also works :!: :?: Maybe it isn't actually freeing the library-- but just exiting w/out erroring :)

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
Don't explicitely unload DLL, if it doesn't crash you have luck. DLL registers itself as a class so it is recorded by local subsistem. I beleive unloading dll is the last thing that should be done after series or other destructors, like unregistering the class, etc...
Posted Image