Solved

Zoom operations for picturebox object

Posted on 2004-09-01
8
307 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

919 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

22 Experts available now in Live!

Get 1:1 Help Now