Now, for an animation control, it will be a static control, and the idea is to just use STM_setimage when the timer set to the frame's delaytime expires. My current problems are:
1) each frame can have a different delay time. i need to figure a way to set a timer, and then execute the next frame on expiration.
2) multiple GIf animation controls should be able to be used without interfering with each other. so i guess using the window's user data and props are viable. but how do you store the ARRAY of images returned by the LoadGIFFrames(), and then reaccess them for each separate control.
The procedure to load GIF frames i have coded returns the hbitmaps in an array. I am thinking it should now be a structured array like:
Code: Select all
Structure ANGIF
hBitmap.l
TransparentColor.l
delaytime.w
EndStructure
dim GIFarray.ANGIF(200)
LoadGIFFrames(filename.s, GIFarray.ANGIF(1))
GifStaticControl(id.l,x.l,y.l,width.l,height.l,GIFarray.ANGIF(1))
Code: Select all
Procedure GIFTimerProc(hwnd,msg,wParam,lParam)
Select msg
Case #WM_TIMER
*ptr=GetProp_(hwnd,"gif") ; get the image array pointer
frame=GetProp_(hwnd,"frame") ; get the frame index
killtimer_(hwnd,200) ; stop the timer
hBitmap=PeekL(*ptr+(frame*SizeOf(ANGIF))) ; get the bitmap. move forward ANGIF size frame # of frames to get the next array element
delaytime=PeekW(*ptr+(frame*SizeOf(ANGIF))+4) ; get the delaytime
SendMessage_(hwnd,#STM_SETIMAGE,#IMAGE_BITMAP,hBitmap); set the new bitmap
setprop_(hwnd,"frame",frame+1) ; increase the frame count
settimer_(hwnd,200,delaytime*10,0) ; set the new timer
EndSelect
ProcedureReturn CallWindowProc_(GetProp_(hwnd,"oldproc"),hwnd,msg,wParam,lParam)
EndProcedure
Procedure GifStaticControl(id.l,x.l,y.l,width.l,height.l,GIFarray.ANGIF(1))
StaticCtl=ImageGadget(id,x.l,y.l,width.l,height,GIFarray(1)\hBitmap)
If id=#PB_Any
PBreturn=StaticCtl
hwnd=GadgetID(StaticCtl)
Else
PBreturn=GadgetID(id)
hwnd=GadgetID(id)
EndIf
setprop_(hwnd,"gif",@GIFarray.ANGIF()) ; set the pointer to the ARRAY of images
setprop_(hwnd,"frame",0) ; set the frame index to 0
settimer_(hwnd,200,GIFarray(1)\delaytime*10,0) ; set the timer with the first frame delay time
setprop_(hwnd,"oldproc",SetWindowLong_(hwnd,#GWL_WNDPROC,@GIFTimerProc())) ; subclass
EndProcedure