Jump to content


Photo

Show animated Gifs in your GUI


  • Please log in to reply
61 replies to this topic

#1 PhiLho

PhiLho
  • Fellows
  • 6850 posts

Posted 16 May 2007 - 01:52 PM

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.



#2 majkinetor

majkinetor
  • Fellows
  • 4511 posts

Posted 16 May 2007 - 02:26 PM

Its not lack of library. Examples clearly show that.

#3 SKAN

SKAN
  • Administrators
  • 9062 posts

Posted 16 May 2007 - 02:33 PM

Great! Many thanks PhiLho, :D

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

:)

#4 majkinetor

majkinetor
  • Fellows
  • 4511 posts

Posted 16 May 2007 - 02:36 PM

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

#5 SKAN

SKAN
  • Administrators
  • 9062 posts

Posted 16 May 2007 - 02:39 PM

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


Sure it is!
Life is Beautiful :D

#6 PhiLho

PhiLho
  • Fellows
  • 6850 posts

Posted 16 May 2007 - 02:43 PM

Updated script, uploaded latest DLL, which is downloaded automatically.

#7 PhiLho

PhiLho
  • Fellows
  • 6850 posts

Posted 16 May 2007 - 02:50 PM

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.

#8 majkinetor

majkinetor
  • Fellows
  • 4511 posts

Posted 16 May 2007 - 04:04 PM

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. :!:

#9 PhiLho

PhiLho
  • Fellows
  • 6850 posts

Posted 16 May 2007 - 04:08 PM

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.

#10 majkinetor

majkinetor
  • Fellows
  • 4511 posts

Posted 16 May 2007 - 04:22 PM

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 :)

#11 PhiLho

PhiLho
  • Fellows
  • 6850 posts

Posted 16 May 2007 - 04:36 PM

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.

#12 freakkk

freakkk
  • Members
  • 182 posts

Posted 16 May 2007 - 04:37 PM

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.

#13 PhiLho

PhiLho
  • Fellows
  • 6850 posts

Posted 16 May 2007 - 04:40 PM

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.

#14 freakkk

freakkk
  • Members
  • 182 posts

Posted 16 May 2007 - 04:44 PM

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 :)

#15 majkinetor

majkinetor
  • Fellows
  • 4511 posts

Posted 16 May 2007 - 04:50 PM

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...