procedure geting_image parameters my_form my_form.addobject("myzoo","cntimgzoom") my_form.myzoo.width=meu_form.width my_form.myzoo.height=meu_form.height my_form.myzoo.zoomimage1.width=meu_form.meuzoo.width my_form.myzoo.zoomimage1.height=meu_form.meuzoo.height my_form.myzoo.zoomimage1.loadimage("D:\Cbr\photos\myland.jpg") && myland.jpg must exists my_form.myzoo.visible=.t. DEFINE CLASS cntimgzoom AS container Width = 129 Height = 116 SpecialEffect = 0 Name = "cntimgzoom" ADD OBJECT zoomimage1 AS zoomimage WITH ; Left = 0, ; Top = 0, ; Name = "Zoomimage1" ADD OBJECT label1 AS label WITH ; AutoSize = .T., ; Caption = "", ; Height = 17, ; Left = 8, ; Top = 4, ; Width = 2, ; BackColor = RGB(255,255,255), ; Name = "Label1" ENDDEFINE * * Class: zoomimage * ParentClass: image * BaseClass: image * DEFINE CLASS zoomimage AS image Height = 180 Width = 240 zoomfactor = 1 Name = "zoomimage" PROTECTED lastx PROTECTED lasty PROTECTED picture PROCEDURE loadimage LPARAMETERS ImageFileName IF EMPTY(ImageFileName) return ENDIF IF FILE(ImageFileName) *ReInit the image size and position ThisForm.LockScreen=.T. This.Stretch=0 This.Picture=ImageFileName * save some Megabytes of memory space... CLEAR RESO This.Top=0 This.Left=0 This.ZoomFactor=1 *change the label caption This.Parent.Label1.Caption='(ZoomFactor: 1X)' ThisForm.LockScreen=.F. ENDIF ENDPROC PROCEDURE Click *Zoom IN by a factor of 2 IF THIS.ZoomFactor < 16 && can be 32 or 64 or 128 ...2^n *...replace this value with the maximum zoom factor you want LOCAL X,Y THISFORM.LOCKSCREEN=.T. THIS.ZoomFactor=THIS.ZoomFactor*2 *Change the label caption IF THIS.ZoomFactor < 1 THIS.PARENT.Label1.CAPTION='(ZoomFactor: 0'+STRTRAN(ALLTRIM(STR(THIS.ZoomFactor,4,3)),'0','')+'X)' ELSE THIS.PARENT.Label1.CAPTION='(ZoomFactor: '+ALLTRIM(STR(THIS.ZoomFactor))+'X)' ENDIF *Resize the image THIS.STRETCH=2 THIS.WIDTH=THIS.WIDTH*2 THIS.HEIGHT=THIS.HEIGHT*2 THIS.TOP=THIS.TOP X=THIS.LastX*2 Y=THIS.LastY*2 *Center the click position on the 'view port' DO CASE CASE X < THIS.PARENT.WIDTH/2 THIS.LEFT=0 CASE THIS.WIDTH < THIS.PARENT.WIDTH THIS.LEFT=0 CASE THIS.WIDTH-X < THIS.PARENT.WIDTH/2 THIS.LEFT= -(THIS.WIDTH-THIS.PARENT.WIDTH) OTHERWISE THIS.LEFT= -(X -( THIS.PARENT.WIDTH/2)) ENDCASE DO CASE CASE Y < THIS.PARENT.HEIGHT/2 THIS.TOP=0 CASE THIS.HEIGHT < THIS.PARENT.HEIGHT THIS.TOP= 0 CASE THIS.HEIGHT-Y < THIS.PARENT.HEIGHT/2 THIS.TOP= -(THIS.HEIGHT-THIS.PARENT.HEIGHT) OTHERWISE THIS.TOP= -(Y-( THIS.PARENT.HEIGHT/2)) ENDCASE *show result THISFORM.LOCKSCREEN=.F. ENDIF ENDPROC PROCEDURE RightClick *Zoom out by a factor of 2 IF THIS.ZoomFactor > 1 && can be 0.5 or 0.25 or 0.125... 2^-n *...replace this value with the minimal zoom factor you want LOCAL X,Y THISFORM.LOCKSCREEN=.T. THIS.ZoomFactor=THIS.ZoomFactor/2 *Change the label caption IF THIS.ZoomFactor < 1 THIS.PARENT.Label1.CAPTION='(ZoomFactor: 0'+STRTRAN(ALLTRIM(STR(THIS.ZoomFactor,4,3)),'0','')+'X)' ELSE THIS.PARENT.Label1.CAPTION='(ZoomFactor: '+ALLTRIM(STR(THIS.ZoomFactor))+'X)' ENDIF *resizing the image THIS.STRETCH=2 THIS.WIDTH=THIS.WIDTH/2 THIS.HEIGHT=THIS.HEIGHT/2 THIS.TOP=THIS.TOP X=THIS.LastX/2 Y=THIS.LastY/2 *Center the click position on the 'view port' DO CASE CASE X < THIS.PARENT.WIDTH/2 THIS.LEFT=0 CASE THIS.WIDTH < THIS.PARENT.WIDTH THIS.LEFT=0 CASE THIS.WIDTH-X < THIS.PARENT.WIDTH/2 THIS.LEFT= -(THIS.WIDTH-THIS.PARENT.WIDTH) OTHERWISE THIS.LEFT= -(X -( THIS.PARENT.WIDTH/2)) ENDCASE DO CASE CASE Y < THIS.PARENT.HEIGHT/2 THIS.TOP=0 CASE THIS.HEIGHT < THIS.PARENT.HEIGHT THIS.TOP= 0 CASE THIS.HEIGHT-Y < THIS.PARENT.HEIGHT/2 THIS.TOP= -(THIS.HEIGHT-THIS.PARENT.HEIGHT) OTHERWISE THIS.TOP= -(Y-( THIS.PARENT.HEIGHT/2)) ENDCASE THISFORM.LOCKSCREEN=.F. ENDIF ENDPROC PROCEDURE MouseDown LPARAMETERS nButton, nShift, nXCoord, nYCoord This.LastX=nXCoord-this.parent.left-this.left This.LastY=nYCoord-This.parent.top-this.top ENDPROC ENDDEFINEHTH