Seite 1 von 1

Animierte GIF direkt auf einem Fenster darstellen.

Verfasst: 22.07.2005 15:08
von mueckerich
Bin darauf gestoßen als ich nach einer Möglichkeit suchte eine GIF direkt
aus dem Speicher abzuspielen. Leider suche ich immer noch. Dafür habe
ich das hier gefunden. Vieleicht kann es jemand brauchen. Viel Spaß damit.

Code: Alles auswählen

;=================================================================================================
;  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, #PB_Window_SystemMenu, "Container-Window") 
If CreateGadgetList(hwnd)
  ButtonGadget(0,250,80,80,40,"End")
EndIf

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 EventGadgetID()
        Case 0: QuitFrm = 1
      EndSelect
    Case #PB_EventCloseWindow
      QuitFrm = 1
  EndSelect 
Until QuitFrm

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

Verfasst: 22.07.2005 18:43
von bingo
animierte gif gibt es bei ms-win-ressource nicht (nur im browser ...) , deswegen gibt es hier sicher keine möglichkeit .

aber einen umweg über avi :

mit pb 3.94 kann man ja eigene ressourcen einbinden und auf diese zugreifen . das trifft auch auf "selbstgemachte" avi zu .

die gif wird z.bsp. mit "gif movie gear" in avi konvertiert . wenn transparent , so wird der transparente farbteil auf 0,255,255 (r,g,b) festgelegt .

die avi kann nun mit den bekannten routinen (mit/ohne transparenz) dargestellt werden .

... das ganze hat auch noch den vorteil , dass die wiedergabe von avi in einem "eigenen" thread läuft und nicht stoppt bei delay , messagebox oder movewindow . die indirekte wiedergabe von gif , flash ... über atl.dll und CreateWindowEx stoppt hier jeweils ! :allright: