Solved

Zoom operations for picturebox object

Posted on 2004-09-01
8
304 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now