2023-11-19 04:53:36 +00:00
': This program uses
': InForm - GUI library for QB64 - Beta version 9
': Fellippe Heitor, 2016-2019 - fellippe@qb64.org - @fellippeheitor
': https://github.com/FellippeHeitor/InForm
'-----------------------------------------------------------
2023-11-20 03:18:12 +00:00
DEFLNG A - Z
OPTION _EXPLICIT
2023-11-19 04:53:36 +00:00
': Controls' IDs: ------------------------------------------------------------------
2023-12-02 16:12:38 +00:00
DIM SHARED DoneProgressBar AS LONG
DIM SHARED AboutButton AS LONG
DIM SHARED GIFPlaySample AS LONG
DIM SHARED GIFPictureBox AS LONG
DIM SHARED LoadButton AS LONG
DIM SHARED PlayButton AS LONG
2023-11-19 04:53:36 +00:00
': External modules: ---------------------------------------------------------------
'$INCLUDE:'../../InForm/extensions/GIFPlay.bi'
2023-11-29 23:28:41 +00:00
'$INCLUDE:'../../InForm/InForm.bi'
2023-11-19 04:53:36 +00:00
'$INCLUDE:'GIFPlaySample.frm'
2023-11-30 21:42:40 +00:00
'$INCLUDE:'../../InForm/InForm.ui'
'$INCLUDE:'../../InForm/extensions/GIFPlay.bas'
2023-11-19 04:53:36 +00:00
': Event procedures: ---------------------------------------------------------------
SUB __UI_BeforeInit
END SUB
SUB __UI_OnLoad
2023-12-02 16:12:38 +00:00
Control ( PlayButton ) . Disabled = TRUE
Control ( DoneProgressBar ) . Disabled = TRUE
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_BeforeUpdateDisplay
2023-12-02 16:12:38 +00:00
IF GIF_IsLoaded ( GIFPictureBox ) THEN
GIF_Draw GIFPictureBox
Control ( DoneProgressBar ) . Value = ( GIF_GetElapsedTime ( GIFPictureBox ) / GIF_GetTotalDuration ( GIFPictureBox ) ) * 100
END IF
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_BeforeUnload
END SUB
SUB __UI_Click ( id AS LONG )
SELECT CASE id
2023-12-02 16:12:38 +00:00
CASE DoneProgressBar
2023-11-30 05:01:22 +00:00
2023-12-02 16:12:38 +00:00
CASE AboutButton
MessageBox "GIFPlay library + InForm-PE demo." + STRING$ ( 2 , 10 ) + "Get it from https://github.com/a740g/InForm-PE" , "About " + Caption ( GIFPlaySample ) , MsgBox_OkOnly + MsgBox_Information
2023-11-19 04:53:36 +00:00
2023-12-02 16:12:38 +00:00
CASE GIFPlaySample
CASE LoadButton
DIM fileName AS STRING : fileName = _OPENFILEDIALOG$ ( Caption ( GIFPlaySample ) , , "*.gif|*.GIF|*.Gif" , "GIF Files" )
2023-11-20 06:46:45 +00:00
IF LEN ( fileName ) > 0 THEN
2023-12-02 16:12:38 +00:00
IF GIF_LoadFromFile ( GIFPictureBox , fileName ) THEN
2023-11-30 05:01:22 +00:00
' Calculate picturebox width based on the aspect ratio of the GIF
2023-12-02 16:12:38 +00:00
Control ( GIFPictureBox ) . Width = GIF_GetWidth ( GIFPictureBox ) / GIF_GetHeight ( GIFPictureBox ) * Control ( GIFPictureBox ) . Height
Control ( GIFPlaySample ) . Width = Control ( GIFPictureBox ) . Width + Control ( LoadButton ) . Width + 24
Control ( DoneProgressBar ) . Width = Control ( GIFPictureBox ) . Width
2023-11-20 06:46:45 +00:00
2023-12-02 16:12:38 +00:00
Control ( DoneProgressBar ) . Disabled = FALSE
2023-11-20 06:46:45 +00:00
2023-12-02 16:12:38 +00:00
IF GIF_GetTotalFrames ( GIFPictureBox ) > 1 THEN
Control ( PlayButton ) . Disabled = FALSE
Caption ( PlayButton ) = "Play"
2023-11-20 06:46:45 +00:00
ELSE
2023-12-02 16:12:38 +00:00
Control ( PlayButton ) . Disabled = TRUE
2023-11-20 06:46:45 +00:00
END IF
2023-11-19 04:53:36 +00:00
ELSE
2023-12-02 16:12:38 +00:00
Control ( PlayButton ) . Disabled = TRUE
Control ( DoneProgressBar ) . Disabled = TRUE
2023-11-20 06:46:45 +00:00
MessageBox fileName + " failed to load!" , "" , MsgBox_Exclamation
2023-11-19 04:53:36 +00:00
END IF
END IF
2023-11-20 06:46:45 +00:00
2023-12-02 16:12:38 +00:00
CASE PlayButton
IF GIF_IsPlaying ( GIFPictureBox ) THEN
GIF_Pause GIFPictureBox
Caption ( PlayButton ) = "Play"
2023-11-19 04:53:36 +00:00
ELSE
2023-12-02 16:12:38 +00:00
GIF_Play GIFPictureBox
Caption ( PlayButton ) = "Pause"
2023-11-19 04:53:36 +00:00
END IF
2023-11-20 06:46:45 +00:00
2023-12-02 16:12:38 +00:00
CASE GIFPictureBox
GIF_EnableOverlay GIFPictureBox , FALSE
2023-11-19 04:53:36 +00:00
END SELECT
END SUB
SUB __UI_MouseEnter ( id AS LONG )
2024-01-11 13:48:38 +00:00
SELECT CASE id
CASE ELSE
END SELECT
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_MouseLeave ( id AS LONG )
2024-01-11 13:48:38 +00:00
SELECT CASE id
CASE ELSE
END SELECT
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_FocusIn ( id AS LONG )
2024-01-11 13:48:38 +00:00
SELECT CASE id
CASE ELSE
END SELECT
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_FocusOut ( id AS LONG )
2024-01-11 13:48:38 +00:00
SELECT CASE id
CASE ELSE
END SELECT
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_MouseDown ( id AS LONG )
2024-01-11 13:48:38 +00:00
SELECT CASE id
CASE ELSE
END SELECT
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_MouseUp ( id AS LONG )
2024-01-11 13:48:38 +00:00
SELECT CASE id
CASE ELSE
END SELECT
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_KeyPress ( id AS LONG )
2024-01-11 13:48:38 +00:00
SELECT CASE id
CASE ELSE
END SELECT
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_TextChanged ( id AS LONG )
2024-01-11 13:48:38 +00:00
SELECT CASE id
CASE ELSE
END SELECT
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_ValueChanged ( id AS LONG )
2024-01-11 13:48:38 +00:00
SELECT CASE id
CASE ELSE
END SELECT
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_FormResized
END SUB