Rick,
I created a sample from
RESOURCE :
Start with original size
Zoom OUT
Zoom IN
Another Solution ( 20 % steps ) :
NO function
NO + / - Buttons
NO Image-click
LOCAL oZSelect1, nZSelect1 := 5 // original
REDEFINE IMAGE oImage ID 510 FILENAME cImage OF oDlg1 PIXEL SCROLL ADJUST BORDER
// NOT NEEDED !!
// oImage:bLClicked := {|| ZOOM_ADJ(oImage, nZoom, "M") } // minus
// oImage:bRClicked := {|| ZOOM_ADJ(oImage, nZoom, "P") } // plus
REDEFINE SELEX oZSelect1 VAR nZSelect1 OF oDlg1 ID 520 ;
ITEMS "-80", "-60", "-40", "-20", "0", "+20", "+40", "+60", "+80", "+100" ;
GRADIENT OUTTRACK { { 0.5, 16443068, 16312263 }, ;
{ 0.5, 16312263, 16443068 } } ;
GRADIENT INTRACK { { 1, 5426223, 1071100 }, ;
{ 1, 1071100, 5426223 } } ;
THUMBSIZE 20, 20 ROUNDSIZE 5 ;
COLOR THUMB 14853684 ;
COLORTEXT 128, 32768 ;
TITLE "Image-zoom" TOP ;
FONT oDataFont ;
ACTION ( nZSelect1 := oZSelect1:nOption, ;
oImage:lStretch := .f., ;
nZoom := oImage:Zoom(), ;
IIF( nZSelect1 = 1, nZoom := 0.2, NIL ), ;
IIF( nZSelect1 = 2, nZoom := 0.4, NIL ), ;
IIF( nZSelect1 = 3, nZoom := 0.6, NIL ), ;
IIF( nZSelect1 = 4, nZoom := 0.8, NIL ), ;
IIF( nZSelect1 = 5, nZoom := 1, NIL ), ;
IIF( nZSelect1 = 6, nZoom := 1.2, NIL ), ;
IIF( nZSelect1 = 7, nZoom := 1.4, NIL ), ;
IIF( nZSelect1 = 8, nZoom := 1.6, NIL ), ;
IIF( nZSelect1 = 9, nZoom := 1.8, NIL ), ;
IIF( nZSelect1 = 10, nZoom := 2, NIL ), ;
oImage:Zoom( nZoom ), oImage:Refresh(), oImage:ScrollAdjust() ) ;
COLORTITLE 0
There seems to be something wrong with the scroll-directions ( very confusing ) :
Right scrollbar-top goes
right
Right scrollbar-bottom goes
left
Bottom scrollbar-left goes
down
Bottom scrollbar-right goes
up
// ------------- DIALOG from Resource --------
FUNCTION SHOW_DLG2()
LOCAL hDC, oImage, nZoom := 0 // Counter for plus or minus
LOCAL cImage := c_path + "\Images\Trash.bmp"
// DEFINE PATH
//c_path := GETCURDIR() // New FWH
//IF !FILE( c_path + "\SETTING.INI" ) // a existing File
// c_path := CURDRIVE() + ":\" + GETCURDIR() // old FWH
//ENDIF
DEFINE DIALOG oDlg1 RESOURCE "Zoom" ;
FONT oBrwFont TITLE "Dialog from RESOURCE" TRANSPARENT
// A Dialog-brush-function
//D_BACKGRD( oDlg1, nDStyle, lDDirect, nDColorF, nDColorB, nDGradPos, cDBrush, cDImage )
REDEFINE IMAGE oImage ID 510 FILENAME cImage OF oDlg1 PIXEL SCROLL ADJUST BORDER
oImage:bLClicked := {|| ZOOM_ADJ(oImage, nZoom, "M") } // minus
oImage:bRClicked := {|| ZOOM_ADJ(oImage, nZoom, "P") } // plus
ACTIVATE DIALOG oDlg1 NOWAIT ;
ON INIT ( ZOOM_ADJ(oImage, nZoom, "S"), ; // ON INIT start with normal size
oDlg1:Move( 60, 30, oDlg1:nWidth, oDlg1:nHeight, .f. ) )
RETURN( NIL )
// ---------------------
FUNCTION ZOOM_ADJ(oBmp, nZoom, cAccion)
LOCAL nZoom0:=oBmp:Zoom()
DO CASE
CASE cAccion == "S"
oBmp:lStretch := !oBmp:lStretch
oBmp:ScrollAdjust()
oBmp:Refresh( .t. )
CASE cAccion == "M"
nZoom-- // a Counter plus / minus, to remember the zoom-status
IF nZoom0 * 10 > 1 .or. nZoom < 1
oBmp:lStretch := .f.
nZoom0 := nZoom0 - ( 0.20 ) // 0.20 = Zoomfactor 20%
oBmp:Zoom( nZoom0 )
oBmp:Refresh()
oBmp:ScrollAdjust()
ENDIF
CASE cAccion == "P"
nZoom++ // a Counter plus / minus
oBmp:lStretch := .f.
nZoom0 := nZoom0 + 0.20
oBmp:Zoom( nZoom0 )
oBmp:Refresh()
oBmp:ScrollAdjust()
ENDCASE
RETURN NIL
Best Regards
Uwe
