Solved

Zoom operations for picturebox object

Posted on 2004-09-01
8
313 Views
Last Modified: 2010-08-05
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
Comment
Question by:blacklord
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 8

Assisted Solution

by:mladenovicz
mladenovicz earned 100 total points
ID: 11951438
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
 
LVL 10

Assisted Solution

by:anv
anv earned 50 total points
ID: 11951682
u can increas the height of the picture box but not the width
width will be adjusted automatically..

0
 

Author Comment

by:blacklord
ID: 11951797
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 10

Expert Comment

by:anv
ID: 11951846
can u put the picture box in Mdi form. then things will work for u ..

width will be adjusted automatically.
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11951909
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
 

Author Comment

by:blacklord
ID: 11952254
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
 
LVL 2

Accepted Solution

by:
kouroshparsa earned 100 total points
ID: 11959141
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
 

Author Comment

by:blacklord
ID: 11960671
ok guys.. Thanks for all.. Here is your points...
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question