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!

VB Code to enlargen an image

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi
I have the problem where I have linked images into a form. Now i want to be able to double click on this image to enlargen the image. I know i have to write code for the double click property, but i dont know the code to write.
I would appreciate any help
Cheers
Klazza
 
Hi,

Depending on exactly how you want it to work, you can use the StretchBlt API or put the image in an imagebox, set the Stretch property to tru and set the size of the image box.

Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
I think one of the easiest ways to do this is to actually create two images of different sizes. Place the images on top of each other and make the larger image visible = "false". Then write in the code on double click of the image you want to make the smaller image visible = "false" and make the larger image visible = "true". Hope this helps.
 
Create a form with a picturebox on it. Drop in the following code:
[tt]
Option Explicit
Private SourcePicture As Picture

Private Sub Form_Load()
Set SourcePicture = LoadPicture("c:\cwb.bmp") ' You put your source image filename in here instead
End Sub

Private Sub Picture1_Click()
Static Zoom As Long ' Staic so we can flip between zoom level
Picture1.Cls
Zoom = Zoom Mod 2 + 1 ' Zoom level toggles between 1 and 2 on each click
Picture1.PaintPicture SourcePicture, 0, 0, Zoom * SourcePicture.Width, Zoom * SourcePicture.Height, , , SourcePicture.Width, SourcePicture.Height
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top