TScrollImg
Source: 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
| DATA | Type | Description |
|---|---|---|
aElements | Array | Array of element definitions (file, URL, action, prompt) |
nImages | Numeric | Number of images loaded from the banner list |
nMode | Numeric | Display mode 1-4 (scroll direction / layout variant) |
nSpeed | Numeric | Scroll speed in pixels per timer tick |
lRunning | Logical | Animation is currently running |
lPaused | Logical | Animation is paused |
aOpacity | Array | Per-image opacity values (0-255) |
nZoomedImage | Numeric | Index of the currently zoomed image (0 = none) |
lFading | Logical | Fading transition is in progress |
lMouseWheel | Logical | Enable mouse wheel scrolling |
lChangeSpeed | Logical | Allow speed change via +/- keys |
Methods
| Method | Description |
|---|---|
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
- The
aBannersarray can contain filenames, or sub-arrays with{ file, url, action, prompt }for extended interactivity. - Mode determines the scroll direction: 1 = horizontal left, 2 = horizontal right, 3 = vertical up, 4 = vertical down.
- When the mouse hovers over an image,
nZoomedImageenables a zoom effect usingnZoomFactor. - Opacity transitions (fading) are applied via
aOpacityandlFading/nFadeDuration. - State persistence with
SaveState/LoadStateallows the carousel to resume from where it left off.