Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image Zoom

Status
Not open for further replies.

mstrcmtr

Programmer
Nov 14, 2007
103
PK
I have a control Image1 in Form1 for display pictures of Products with Stretch set to 2-Stretch

Further want to Zoom + or - to see product picture more closely

How to set Zoom option ?
 
There are a lot of ways to go about this.
The "dynamic" zoom I find a little problematic, so I usually allow a "normal" view and a "Zoom" view, but that zoom is fixed. I just do this by clicking on the image directly (with a "zoom" mouse icon + or - to expand or reduce). Then on the plus just set that This.Height and This.Width and This.Top and This.Left values to what you want them to be for the form size you have.

In the Click Event:
Code:
IF THIS.Width > 1000 && This means we want to shink it back to regular size
  WITH THIS
    .HEIGHT = 640
    .WIDTH = 320
    .TOP = 100
    .LEFT = 25
  ENDWITH
ELSE && This means we make it big again
   WITH THIS
     .HEIGHT = 1024
     .WIDTH = 768
     .TOP = 0
     .LEFT = 0
   ENDWITH
ENDIF

The above is an example of how you might do it, the positions are all dependant upon the original size of your image object.

If you wanted to get really clever, you could put a slider bar in that allows an increase by some %. Then you'll need to dynamically track the physical sizes, and keep your original size. You could do that as a hard-code, or capture the size of the object after it instantiates, and hold those values as variables. This is nice because if you change the default size in your form later, you don't have to reprogram the start size and position.

Best Regards,
Scott
MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."[hammer]
 
The code that Scott has given you will cause the entire picture to expand or contract, taking up more or less space on the form. Is that what you want?

What I suspect you want is to see part of the picture in a larger size while retaining the overall size of the image control. In other words, so that the boundaries of the image don't change, even if that means clipping off part of the image.

Perhaps you could confirm which of those approaches you are looking for.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Several years ago I posted about this in my blog:
[URL unfurl="true"]http://tomsvfpblog.blogspot.de/2008/02/bilder-zur-laufzeit-in-einem-form.html[/url]

To sum it up, you have to place a container on your form that defines the visible part of the picture. Into the container, you place your picture object and with mousescroll you can zoom it in and out.

So, have a look at my blogpost, it's from 2008 but will still work fine.

BTW, though my blog is in german, you can let it translate to bad english via Google translate on the right side of the blog...

HTH

-Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top