TScrollImg

Fuente: source/classes/scrolimg.prg

Inherits from: TPanel

TScrollImg is an image banner / carousel control that displays a scrolling collection of images. It supports multiple display modes, automatic animation, fading transitions, zoom on hover, click actions per image, and state persistence. Originally designed for product showcases and advertisement banners.

Key DATA Members

DATATypeDescription
aElementsArrayArray of element definitions (file, URL, action, prompt)
nImagesNumericNumber of images loaded from the banner list
nModeNumericDisplay mode 1-4 (scroll direction / layout variant)
nSpeedNumericScroll speed in pixels per timer tick
lRunningLogicalAnimation is currently running
lPausedLogicalAnimation is paused
aOpacityArrayPer-image opacity values (0-255)
nZoomedImageNumericIndex of the currently zoomed image (0 = none)
lFadingLogicalFading transition is in progress
lMouseWheelLogicalEnable mouse wheel scrolling
lChangeSpeedLogicalAllow speed change via +/- keys

Methods

MethodDescription
New( nRow, nCol, nW, nH, oWnd, aBanners, nMode, nSpeed, ... )Create a new image carousel with banner file list and display mode
Redefine( nId, oWnd, aBanners, nMode, nSpeed, ... )Redefine from a dialog resource
Reset()Reset the carousel to its initial state, reposition all images
Animate()Start or restart the scrolling animation timer
Paint()Render the background and all visible images
TimerAction()Timer callback that advances the scroll position each tick
SaveState( cFile )Save the current carousel state (positions, images) to a file
LoadState( cFile )Restore a previously saved carousel state from a file
MouseMove( nRow, nCol )Handle mouse movement for hover detection and zoom
LButtonUp( nRow, nCol )Execute action associated with the clicked image
KeyDown( nKey, nFlags )Handle +/- keys for speed control
MouseWheel( nKeys, nDelta, nX, nY )Handle mouse wheel for manual scrolling

Example: Image Carousel

#include "FiveWin.ch"

function Main()

   local oWnd, oScroll

   DEFINE WINDOW oWnd TITLE "Image Carousel" SIZE 800, 300

   oScroll = TScrollImg():New( 10, 10, 780, 240, oWnd,;
      { "banner1.jpg", "banner2.jpg", "banner3.jpg", "banner4.jpg" },;
      1, 3, 20 )

   oScroll:Animate()

   ACTIVATE WINDOW oWnd CENTERED

return nil

Notes

Ver También