[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

Zoom operations for picturebox object

Hi there...

Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Dim oldwnd As Long

oldwnd = SetParent(Me.hWnd, Form2.Picture1.hWnd)

I have used the code above to display the form1 into the pictureBox object located in form2.

My question is; Is it possible to make zoom in / zoom out operations for that picture object?

Thanks...
0
blacklord
Asked:
blacklord
  • 3
  • 2
  • 2
  • +1
3 Solutions
 
mladenoviczCommented:
Try this

Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

StretchBlt Form2.Picture1.hdc, 1, 1, Form1.Width * 2, Form1.Height * 2, Form2.Picture1.hdc, 1, 1, Form1.Width, Form1.Height, &HCC0020


0
 
anvCommented:
u can increas the height of the picture box but not the width
width will be adjusted automatically..

0
 
blacklordAuthor Commented:
any width is not adjusted.

Mladenovicz I used that code but it is not reponding.

I just want to increase the view of the form1 inside the picture box.

Thnks...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
anvCommented:
can u put the picture box in Mdi form. then things will work for u ..

width will be adjusted automatically.
0
 
mladenoviczCommented:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long

Private Sub Command2_Click()
Dim oldwnd As Long

oldwnd = SetParent(Me.hWnd, Form2.Picture1.hWnd)
Me.Move 1, 1
End Sub

Private Sub Command1_Click()
    Form2.Show
End Sub

Private Sub Command3_Click()
     StretchBlt Form2.Picture1.hdc, 1, 1, Form1.Width * 2, Form1.Height * 2, Form2.Picture1.hdc, 1, 1, Form1.Width, Form1.Height, &HCC0020
End Sub

Here is the project with two forms. First form need three command buttons. Form2 need picture box. Click Command1, Command2, Command3
0
 
blacklordAuthor Commented:
mlandenovic ;
StretchBlt Form2.Picture1.hdc, 1, 1, Form1.Width * 2, Form1.Height * 2, Form2.Picture1.hdc, 1, 1, Form1.Width, Form1.Height, &HCC0020
this doesnt make any change.


0
 
kouroshparsaCommented:
Try this:
To zoom:
picture1.PaintPicture picture1.Image, 0, 0, picture1.Width * 0.8, picture1.Height * 0.8


0.8 is the constant of scale

1 means 100% (no zoom)
0.5 means 50%
2 means 200%
0
 
blacklordAuthor Commented:
ok guys.. Thanks for all.. Here is your points...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now