FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A solution for BTNBMP using animated GIF's
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
A solution for BTNBMP using animated GIF's
Posted: Mon Jun 20, 2016 10:25 AM
Hello,

is it possible to display a animated GIF inside BTNBMP ?

I can use a TRANSPARENT button and split the animated GIF to it single images
Next using oBtn:SetFile(Frame&No.gif ) inside a loop on buttonclick
but I need up to 20 single images.
Next to perform the ACTION during the GIF is running.
Maybe possible ?

It would be a nice extension of BTNBMP.
For the moment only the 1. image is displayed.



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: BTNBMP with animated GIF ?
Posted: Mon Jun 20, 2016 02:04 PM
I do not understand your needs
But this works for me

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "gif.ch"

function Main()

   local oDlg, oBtn

   DEFINE DIALOG oDlg TITLE "Attention" SIZE 400, 600

   @ 2, 11 BUTTONBMP oBtn PROMPT "Waiting to use the calculator" SIZE 120, 200 PIXEL ACTION MsgInfo( "Hello" )

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT PlaceGif( oBtn )

return nil

function PlaceGif( oDlg )

   local oGif

   @ 19, 10 GIF oGif FILENAME "..\gifs\gif05.gif" OF oDlg

return nil
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: BTNBMP with animated GIF ?
Posted: Mon Jun 20, 2016 02:24 PM
Cristobal,

that is NOT the result, I'm looking for
the problem : the animated GIF is NOT shown transparent and the button-action is disabled
as well NO tooltip and NO prompt is visible !!!

You can download my complete sample, to see what I mean :
( as well You can enable Your solution < PLACEGIF > for a test )

http://www.pflegeplus.com/DOWNLOADS/Anigif2.zip

the RESULT using function < PLACEGIF >



my solution :
replacing the button-image calling a gif-paint-function

@ 30, 85 BTNBMP oBtn[7] SIZE 90, 90 OF oDlg 2007 ;
FILENAME c_path1 + "Animat_1.gif" ; // the 1. image of a set. Using a animated gif, only the 1. image is visible
CENTER ROUND ;
PROMPT "&Run .." ;
FONT oTextFont ;
ACTION ( RUN_ACTION(oBtn), lRun := .T., GIF_RUN(oBtn) )
// calling the single images of a defined set. The animated GIF is splitted to the single-images
oBtn[7]:lTransparent := .T.
oBtn[7]:SetColor( 128 )
oBtn[7]:cTooltip := { "RUN" + CRLF + ;
"animated GIF","RUN", 1, CLR_BLACK, 14089979 }

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: BTNBMP using animated GIF's ?
Posted: Mon Jun 20, 2016 06:57 PM
Uwe, your sample run OK, for me

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: BTNBMP using animated GIF's ?
Posted: Mon Jun 20, 2016 07:28 PM

Uwe, sorry,
Now I understand your problem
I'll investigate

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: BTNBMP using animated GIF's ?
Posted: Mon Jun 20, 2016 07:59 PM

Cristobal,

I added another set in blue using bmp-format NO alpha < 1.bmp - 18.bmp >
( works as well and can be created as resource )
added a different start and endimage

The solution could be used like in windows shutdown or start ( with button-style NOBORDER )

http://www.pflegeplus.com/DOWNLOADS/Anigif2.zip

regards
Uwe :D

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: BTNBMP using animated GIF's ?
Posted: Mon Jun 20, 2016 10:09 PM
Cristobal . Si interesa tengo algo con gdiplus que funciona con un c贸digo muy similar pero sin crear los frames externos ...
el c贸digo seria similar a esto . ( faltar铆a liberar hbitmaps )
el exe funcionando https://www.dropbox.com/s/srnfuaa84h9rn ... n.exe?dl=0
Code (fw): Select all Collapse
FUNCTION GIF_RUN(oBtn)
local hbitmap
local hbmpFrame
local hbmp
LOCAL I := 1 
local nLen 

hbmp:= GDIPLUSIMAGEFFILE( c_path1 + "animat" + ".gif" )
if  GDIPLUSISANIMATEDGIF( hbmp ) 
    nLen:= GDIPLUSIMGGETFRAMECOUNT(hbmp)
    DO WHILE lRun = .T.
    FOR I := 1 TO nLen
        IF lRun = .F.
            EXIT
        ENDIF
               hbmpFrame := GDIPLUSIMGGETFRAME(hbmp, i)
               hBitmap:= GdiPlusCreateHBitmapImage( hbmpFrame )
               oBtn[7]:LoadBitmaps(  bitmap )
               oBtn[7]:Refresh()
        SYSWAIT(0.1)
    NEXT
   ENDDO
endif
oBtn[7]:Refresh()

RETURN NIL
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: BTNBMP using animated GIF's ?
Posted: Mon Jun 20, 2016 10:20 PM

Manuel, si, eso ya lo hab铆a visto, muchas gracias
El problema es que cuando se muestra un GIF ( no las im谩genes sucesivamente como ahora ), el GIF no se muestra transparente

Saludos

Manuel, yes, that I had already seen, thank you very much
The problem is that when shown a GIF (not images successively as now), the GIF is not displayed transparent

Regards

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: BTNBMP using animated GIF's ?
Posted: Tue Jun 21, 2016 08:52 AM
cnavarro wrote:Manuel, si, eso ya lo hab铆a visto, muchas gracias
El problema es que cuando se muestra un GIF ( no las im谩genes sucesivamente como ahora ), el GIF no se muestra transparente

Saludos

Manuel, yes, that I had already seen, thank you very much
The problem is that when shown a GIF (not images successively as now), the GIF is not displayed transparent

Regards


Cristobal en mis pruebas aqui ....

si uso como imagen

@ 30, 85 BTNBMP oBtn[7] SIZE 90, 90 OF oDlg 2007 ;
FILENAME c_path1 + "Animat_1" + ".gif" ;

la imagen me sale con fondo negro


@ 30, 85 BTNBMP oBtn[7] SIZE 90, 90 OF oDlg 2007 ;
FILENAME c_path1 + "Animat" + ".gif" ;

la imagen sale trasparente .

Si miras la diferencia entre ellas es que 茅sta ultima su tipo es RGB 8 bits mientras la otra es indexado 8 bits.
Parece que gdiplus no detecta correctamente como trasparente las imagenes indexadas .
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: BTNBMP using animated GIF's ?
Posted: Wed Jun 22, 2016 11:01 AM
Cristobal,

I added some more tests and all animations are working fine
Some new sets are added and working with resources.





1 small problem with sample 2 :
A button-animation is running as long < lRun = .T. >
Is there a way as soon closing MS-calc.exe, to set < lRun = .F.> to stop the animation ?

I tested inside the loop with
MsgAlert( IsExeRunning( "calc.exe" ) )
1. lRun starts with .F.
2. after open calc.exe lRun shows .T.
3. closing calc.exe < IsExeRunning( "calc.exe" ) > still shows .T.

Code (fw): Select all Collapse
FUNCTION GIF_RUN2(oBtn)
LOCAL I := 1 

DO WHILE lRun = .T.
聽 聽MsgAlert( IsExeRunning( "calc.exe" ) )
聽 聽IF !IsExeRunning( "calc.exe" ) // .F. for animation break
聽 聽 聽 lRun := .F.
聽 聽ENDIF
聽 聽FOR I := 1 TO 18
聽 聽 聽 IF lRun = .F.
聽 聽 聽 聽 聽EXIT
聽 聽 聽 ENDIF
聽 聽 聽 oBtn[8]:SetFile( c_path1 + "A_" + LTRIM(STR(I)) + ".gif" )
聽 聽 聽 oBtn[8]:Refresh()
聽 聽 聽 SYSWAIT(0.1)
聽 聽NEXT
ENDDO
oBtn[8]:SetFile( c_path1 + "Calc.bmp" )
oBtn[8]:Refresh()

RETURN NIL


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: BTNBMP using animated GIF's ?
Posted: Wed Jun 29, 2016 06:52 PM
I added some more tests
New : sample using a DLL and a sample running a external EXE-file

1. I splitted the anigif to single frames
2. converted the frames to BMP
3. created a DLL
4. added the frames using numeric resource-names
5. calling the resources from inside a FOR / NEXT for the button



Code (fw): Select all Collapse
// the DLL includes the frames from < C_1.bmp to C_12.bmp >

FUNCTION GIF_RUN4(cStyle, oBtn)
LOCAL I := 1 

DO WHILE lRun = .T.
聽 聽 FOR I := 1 TO 12
聽 聽 聽 聽 IF lRun = .F.
聽 聽 聽 聽 聽 聽 EXIT
聽 聽 聽 聽 ENDIF
聽 聽 聽 聽 oABtn[4]:SetFile( cStyle + LTRIM(STR(I)) ) // resource from DLL
聽 聽 聽 聽 oABtn[4]:Refresh()
聽 聽 聽 聽 SYSWAIT(0.1)
聽 聽 NEXT
ENDDO
oABtn[4]:SetFile( c_path1 + "Dll.bmp" )
oABtn[4]:Refresh()

RETURN NIL


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion