Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can i make an image scrollable?
Message
De
10/03/2003 16:02:02
 
 
À
10/03/2003 15:03:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00763873
Message ID:
00763908
Vues:
28
Vim;
>i have a client that scans in letters they send to their customers. the letters used to be one page long and therefore were readable when viewed full screen in VFP. however the letters now can be up to 10 pages long. the customer would like to place all ten pages into one very long .JPG image file. anyone have any suggestions how i can change my picture box on my VFP 7.0 form such that they can scroll down and view each page. the other option is to have a .TIF file that has ten pages in it.
>

To produce a scroll, just create a form with both scrolls and it will work fine.. Just do it creating an image object bigger than the form (with clip adjustment)

But, If you want to control a zoom on it.. Here is a function that produces a zoom on an given image.. (I got that some days ago, here at UT)


On a form's load, just do:

do geting_image with this
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
ENDDEFINE
HTH

Claudio
"Now to him who is able to do immeasurably more than all we ask or imagine, according to his power that is at work within us, Ephesians 3:20
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform