|
-
Jun 30th, 2000, 03:21 PM
#1
Thread Starter
Addicted Member
CAn any one show me by example how I may use the Plus ('+') & minus ('-') keys on the key pad to soom into & out of a picture in a picture box.
Keeping the image in proportion, like you didn't know that
Thanks in advance!!
Ram
-
Jun 30th, 2000, 04:08 PM
#2
If you place your picture in an ImageBox you can use this code.
Put this in the KeyDown event of the Form.
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyAdd Then
Image1.Stretch = True
Image1.Width = Image1.Width * 2
Image1.Height = Image1.Height * 2
End If
If KeyCode = vbKeySubtract Then
Image1.Stretch = True
Image1.Width = Image1.Width / 2
Image1.Height = Image1.Height / 2
End If
End Sub
Private Sub Form_Load()
Me.KeyPreview = True
Image1.Stretch = True
End Sub
-
Jun 30th, 2000, 06:26 PM
#3
transcendental analytic
Without replacing it with a Imagebox you could use this code:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim speed As Integer
Select Case Chr(KeyCode)
Case "-"
speed = 10
Case "+"
speed = -10
Case Else
Exit Sub
End Select
With Picture1
.Picture = .Image
.PaintPicture Picture1, 0, 0, .ScaleWidth, .ScaleHeight, .ScaleWidth / speed, .ScaleHeight / speed, .ScaleWidth - .ScaleWidth / speed * 2, .ScaleHeight - .ScaleHeight / speed * 2
End With
End Sub
justify speed for your needs
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 30th, 2000, 07:24 PM
#4
Here is another way that is keeping the PictureBox. For this, you need to create 2 PictureBoxes. Load your Picture into Picture2.
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyAdd Then
With Picture1
.Cls
.Width = .Width * 2
.Height = .Height * 2
.PaintPicture Picture2.Picture, 0, 0, .ScaleWidth, .ScaleHeight
End With
End If
If KeyCode = vbKeySubtract Then
With Picture1
.Cls
.Width = .Width / 2
.Height = .Height / 2
.PaintPicture Picture2.Picture, 0, 0, .ScaleWidth, .ScaleHeight
End With
End If
End Sub
Private Sub Form_Load()
Picture2.Visible = False
Me.KeyPreview = True
Picture1.AutoRedraw = True
Picture1.PaintPicture Picture2.Picture, 0, 0
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|