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-11-30 05:01:22 +00:00
DIM SHARED AboutBT AS LONG
2023-11-19 04:53:36 +00:00
DIM SHARED gifplaySample AS LONG
DIM SHARED PictureBox1 AS LONG
DIM SHARED LoadBT AS LONG
DIM SHARED PlayBT AS LONG
': External modules: ---------------------------------------------------------------
'$INCLUDE:'../../InForm/extensions/GIFPlay.bi'
2023-11-20 03:18:12 +00:00
'$INCLUDE:'../../InForm/extensions/MessageBox.bi'
2023-11-29 23:28:41 +00:00
'$INCLUDE:'../../InForm/InForm.bi'
2023-11-19 04:53:36 +00:00
'$INCLUDE:'GIFPlaySample.frm'
': Event procedures: ---------------------------------------------------------------
SUB __UI_BeforeInit
END SUB
SUB __UI_OnLoad
2023-11-29 06:24:06 +00:00
Control ( PlayBT ) . Disabled = TRUE
2023-11-19 04:53:36 +00:00
END SUB
SUB __UI_BeforeUpdateDisplay
2023-11-29 06:24:06 +00:00
IF GIF_IsLoaded ( PictureBox1 ) THEN GIF_Draw PictureBox1
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-11-30 05:01:22 +00:00
CASE AboutBT
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
CASE gifplaySample
CASE LoadBT
2023-11-20 06:46:45 +00:00
DIM fileName AS STRING : fileName = _OPENFILEDIALOG$ ( Caption ( gifplaySample ) , , "*.gif|*.GIF|*.Gif" , "GIF Files" )
IF LEN ( fileName ) > 0 THEN
2023-11-23 03:47:14 +00:00
IF GIF_LoadFromFile ( PictureBox1 , fileName ) THEN
2023-11-30 05:01:22 +00:00
' Calculate picturebox width based on the aspect ratio of the GIF
Control ( PictureBox1 ) . Width = GIF_GetWidth ( PictureBox1 ) / GIF_GetHeight ( PictureBox1 ) * Control ( PictureBox1 ) . Height
Control ( gifplaySample ) . Width = Control ( PictureBox1 ) . Width + Control ( LoadBT ) . Width + 24
2023-11-20 06:46:45 +00:00
2023-11-29 06:24:06 +00:00
Control ( PlayBT ) . Disabled = FALSE
2023-11-20 06:46:45 +00:00
IF GIF_GetTotalFrames ( PictureBox1 ) > 1 THEN
Caption ( PlayBT ) = "Play"
ELSE
2023-11-29 06:24:06 +00:00
Control ( PlayBT ) . Disabled = TRUE
2023-11-20 06:46:45 +00:00
END IF
2023-11-19 04:53:36 +00:00
ELSE
2023-11-29 06:24:06 +00:00
Control ( PlayBT ) . 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-11-19 04:53:36 +00:00
CASE PlayBT
2023-11-20 03:18:12 +00:00
IF GIF_IsPlaying ( PictureBox1 ) THEN
GIF_Pause PictureBox1
2023-11-19 04:53:36 +00:00
Caption ( PlayBT ) = "Play"
ELSE
2023-11-20 03:18:12 +00:00
GIF_Play PictureBox1
2023-11-19 04:53:36 +00:00
Caption ( PlayBT ) = "Pause"
END IF
2023-11-20 06:46:45 +00:00
2023-11-19 04:53:36 +00:00
CASE PictureBox1
2023-11-29 06:24:06 +00:00
GIF_EnableOverlay PictureBox1 , FALSE
2023-11-19 04:53:36 +00:00
END SELECT
END SUB
SUB __UI_MouseEnter ( id AS LONG )
END SUB
SUB __UI_MouseLeave ( id AS LONG )
END SUB
SUB __UI_FocusIn ( id AS LONG )
END SUB
SUB __UI_FocusOut ( id AS LONG )
END SUB
SUB __UI_MouseDown ( id AS LONG )
END SUB
SUB __UI_MouseUp ( id AS LONG )
END SUB
SUB __UI_KeyPress ( id AS LONG )
END SUB
SUB __UI_TextChanged ( id AS LONG )
END SUB
SUB __UI_ValueChanged ( id AS LONG )
END SUB
SUB __UI_FormResized
END SUB
'$INCLUDE:'../../InForm/InForm.ui'
'$INCLUDE:'../../InForm/xp.uitheme'
2023-11-20 03:18:12 +00:00
'$INCLUDE:'../../InForm/extensions/MessageBox.bas'
2023-11-29 23:28:41 +00:00
'$INCLUDE:'../../InForm/extensions/GIFPlay.bas'