GDI+ GIF Animation Control with FireFly

Started by Jean-Pierre LEROY, January 11, 2009, 08:41:17 AM

Previous topic - Next topic

Jean-Pierre LEROY

Some months ago, Jose Roca published a custom control called "GDIPANIMCTX" to display an animated .GIF file.

Here is the link to the source code published by Jose Roca

http://www.jose.it-berater.org/smfforum/index.php?topic=2681.0

I would like to know how to use it with FireFly.

Thanks.
Jean-Pierre



TechSupport

Hi Jean-Pierre,

Sorry - I missed your post earlier. The following code works well in FireFly.

Assumes that the main form is called "frmMain". You also need to download Jose's GDI headers from http://www.jose.it-berater.org/smfforum/index.php?topic=88.0

The example below is essentially a one-to-one translation of the example program that Jose includes in his source package.


#INCLUDE "TB_GDIPANIMCTX.INC"

Global gtoken As Dword

%IDC_GDIPANIM = 100


'------------------------------------------------------------------------------------------------------------------------
Function FRMMAIN_WM_CREATE ( _
                           hWndForm As Dword, _  ' handle of Form
                           ByVal UserData As Long _  'optional user defined Long value
                           ) As Long

   Local hCtl       As Dword
   Local szFileName As Asciiz * %MAX_PATH
   Local tDataEx    As TB_GDIPANIMDATAEX

   ' =====================================================================================
   ' Create the control
   ' =====================================================================================
   ' Required: Intialize the control
   TB_InitGdipAnimCtx   
   
   ' Optional: Extra creation data
   tDataEx.QualityMode = %QualityModeHigh
   tDataEx.BackColor   = %BLUE
   
   ' Create an instance of the control
   ' szFileName is the full path of the animated .GIF file
   szFileName = App.Path & "piper-20.gif"   ' ---> change me!

   hCtl = CreateWindowEx(0, "TB_GDIPANIMCTX", szFileName, %WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %WS_BORDER, _
          0, 0, 0, 0, hWndForm, %IDC_GDIPANIM, App.hInstance, tDataEx)

End Function




'------------------------------------------------------------------------------------------------------------------------
Function FRMMAIN_WM_SIZE ( _
                         hWndForm      As Dword, _  ' handle of Form
                         fwSizeType    As Long,  _  ' type of resizing request
                         nWidth        As Long,  _  ' new width of client area
                         nHeight       As Long   _  ' new height of client area
                         ) As Long

   SetWindowPos GetDlgItem(hWndForm, %IDC_GDIPANIM), %HWND_TOP, 0, 0, nWidth, nHeight, %SWP_SHOWWINDOW
   
End Function


'------------------------------------------------------------------------------------------------------------------------
Function FRMMAIN_WM_DESTROY ( _
                            hWndForm      As Dword _  ' handle of Form
                            ) As Long
                           
   ' === Required: Shutdown GDI+ =========================================================
   GdiplusShutdown gtoken
   ' =====================================================================================

End Function


Here is the FF_WinMain function:


Function FF_WINMAIN(ByVal hInstance     As Dword, _
                    ByVal hPrevInstance As Dword, _
                    ByVal lpCmdLine     As Asciiz Ptr, _
                    ByVal iCmdShow      As Long) As Long


   'If this function returns TRUE (non-zero) then the actual WinMain will exit
   'thus ending the program. You can do program initialization in this function.


   LOCAL hr AS LONG
   LOCAL StartupInput AS GdiplusStartupInput

   ' === Required: Initialize GDI+ =======================================================
   StartupInput.GdiplusVersion = 1
   hr = GdiplusStartup(gtoken, StartupInput, ByVal %Null)
   IF hr THEN
      MSGBOX "Error initializing GDI+"
      EXIT FUNCTION
   END IF
   
   Function = %FALSE    'return %TRUE if you want the program to end.

End Function




Jean-Pierre LEROY

Hi Paul,

I made some test in FF2.95.

At first I have to correct theses lines of code :


'#Include "TB_GDIPANIMCTX.INC"
#Include "GDIPANIMCTX.INC"



'Local tDataEx    As TB_GDIPANIMDATAEX   
Local tDataEx As GDIPANIMCTXDATAEX



' Required: Intialize the control
'TB_InitGdipAnimCtx   
InitGdipAnimCtx


After theses corrections I have no problem to compile my project with Jose Include Files, but I can't see the animated GIF file on the screen.

Any ideas ?

Thanks.
Jean-Pierre.

Jose Roca

Quote
Any ideas?

Yes. Use "GDIPANIMCTX" as the class name instead of "TB_GDIPANIMCTX" in


   hCtl = CreateWindowEx(0, "TB_GDIPANIMCTX", szFileName, %WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %WS_BORDER, _
          0, 0, 0, 0, hWndForm, %IDC_GDIPANIM, App.hInstance, tDataEx)


Jean-Pierre LEROY

I had not seen this one!

Thank you Jose, I made the modification and now it works perfectly.

Jean-Pierre