Solved

Zoom operations for picturebox object

Posted on 2004-09-01
8
310 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB error "Type mismatch" 2 53
Saving history changes to sub form 4 42
Excel - Save a copy of work book 13 84
vbModal 12 51
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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

813 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