Display animated GIF directly in a Window

Share your advanced PureBasic knowledge/code with the community.
mueckerich
User
User
Posts: 22
Joined: Thu Dec 16, 2004 10:36 am
Location: Germany/Allgaeu

Display animated GIF directly in a Window

Post by mueckerich »

Code updated For 5.20+

As i look for a Method to display Animated GIF directly from Memory without save them on HD. I did not found what i'm looking for but i found this. Maybe someone can use it.
BTW I'm still searching. :?:

Code: Select all

;=================================================================================================
; Autor : Michael Holderried (mueckerich)
; Modul Name : AniGIFForm.pb
; Description : Displays an animated GIF directly on a Form, which can be also moved.
; BuildDate : 22.07.2005
;================================================================================================


;- Window Constants
;
#Window_0 = 0
#SizeWindowX = 400
#SizeWindowY = 200

#SS_CENTERIMAGE = $200
#WS_EX_TRANSPARENT = $20

sWin.s

hwnd = OpenWindow(#Window_0, 400, 200, #SizeWindowX , #SizeWindowY, "Container-Window", #PB_Window_SystemMenu)

ButtonGadget(0,250,80,80,40,"End")

If OpenLibrary(0,"ATL.DLL")
  If CallFunction(0,"AtlAxWinInit") ; Init has to be done to register the ATL Class "AtlAxWin"
    sWin = "F:\Projekte\PRJ_PB\BYFLAG.GIF" ; Thats an Example how to dispaly a lokal stored GIF Animation
    ; sWin = "http://www.Somwhere.de//MyGif.gif" ; This Example shows how you can get the GIF Animation from the WEB
    ; now we create the Window for our GIF, it might be possible to create this Window as Topmost Parent?
    hAxW = CreateWindowEx_(#WS_EX_TRANSPARENT | #SS_CENTERIMAGE, "AtlAxWin", sWin, #WS_VISIBLE | #WS_POPUP , 0, 0, 200, 200, hwnd, 0, GetModuleHandle_(0), 0)
    If hAxW
      SetParent_(hAxW, hwnd) ; Set GIF-Window as Child Window from our Container. Otherwise
    EndIf ; it will be a Window which can also be outside of our Container
  EndIf ; Try it out! (comment out SetParent)
EndIf

QuitFrm = 0
Repeat
  EventID = WaitWindowEvent()
  Select EventID
    Case #WM_LBUTTONDOWN
      ReleaseCapture_()
      ;SendMessage_(hwnd, #WM_SYSCOMMAND, #SC_MOVE + #HTCAPTION, 0) ;To move (Drag) the Container Window
      SendMessage_(hAxW, #WM_SYSCOMMAND, #SC_MOVE + #HTCAPTION, 0) ;To move (Drag) the GIF within the Container Window
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0: QuitFrm = 1
      EndSelect
    Case #PB_Event_CloseWindow
      QuitFrm = 1
  EndSelect
Until QuitFrm

DestroyWindow_(hAxW) ; We have to desroy the Windows, otherwise you'll get a exeption
End 
Believe means you don't know