?
Solved

Using PaintPicture without any Picture

Posted on 2001-09-03
6
Medium Priority
?
535 Views
Last Modified: 2008-02-01
Hi.

I want to "draw" on a PictureBox and then use the method
Picture1.PaintPicture to copy the drawings to another Picturebox.

But I can't do that.
If I try to "PaintPicture" without having assigned a picture to the source PictureBox first
I got "invalid Picture" and if I assign a picture and then make some drawing on it using Picture1.Line or Picture1.Pset the only thing that will be copied is the original picture, not my drawings.

Is it not possible to copy "drawings" between pictureboxes
using standard PictureBoxes rutines.

Per

0
Comment
Question by:PerBoman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6450202
Hi PerBoman,

Last 10 Grades Given C B C C C B B B B B  ..
0
 
LVL 4

Expert Comment

by:WolfgangKoenig
ID: 6450285
You can use the properties Image and Picture to do this.
Here is an example:

This example draws a circle in the first PictureBox control each time you click it. When you click the second PictureBox, the graphic from the first PictureBox is copied into it. To try this example, paste the code into the Declarations section of a form that has two large, equal-sized PictureBox controls. Press F5 to run the program, and then click the PictureBox controls.

Private Sub Form_Load ()
   ' Set AutoRedraw to True.  
   Picture1.AutoReDraw = True
End Sub

Private Sub Picture1_Click ()
 ' Declare variables.
   Dim PW, PH
 ' Set FillStyle to Solid.
   Picture1.FillStyle = vbFSSolid  
 ' Choose random color.
   Picture1.FillColor = QBColor(Int(Rnd * 15))
   PW = Picture1.ScaleWidth   ' Set ScaleWidth.
   PH = Picture1.ScaleHeight   ' Set ScaleHeight.
   ' Draw a circle in random location.
   Picture1.Circle (Int(Rnd * PW), Int(Rnd * PH)), 250
End Sub

Private Sub Picture2_Click ()
 ' Copy Image to Picture2.
   Picture2.Picture = Picture1.Image
End Sub


Best regards
WoK
0
 

Author Comment

by:PerBoman
ID: 6450359
How do I do then if I only want to copy
a portion of the image?
(like one could in PaintPicture)
0
Technology Partners: 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!

 
LVL 4

Expert Comment

by:WolfgangKoenig
ID: 6450517
Use this:
Private Sub Form_Load()
 Picture2.PaintPicture Picture1.Image, 0, 0
End Sub

WoK
0
 
LVL 4

Accepted Solution

by:
WolfgangKoenig earned 800 total points
ID: 6450520
Complete is:
Private Sub Form_Load()
  ' Set AutoRedraw to True.
  Picture1.AutoRedraw = True
End Sub

Private Sub Picture1_Click()
' Declare variables.
  Dim PW, PH
' Set FillStyle to Solid.
  Picture1.FillStyle = vbFSSolid
' Choose random color.
  Picture1.FillColor = QBColor(Int(Rnd * 15))
  PW = Picture1.ScaleWidth   ' Set ScaleWidth.
  PH = Picture1.ScaleHeight   ' Set ScaleHeight.
  ' Draw a circle in random location.
  Picture1.Circle (Int(Rnd * PW), Int(Rnd * PH)), 250
End Sub

Private Sub Picture2_Click()
' Copy Image to Picture2.
Picture2.PaintPicture Picture1.Image, 0, 0
End Sub

Thats was it ...
WoK
0
 

Author Comment

by:PerBoman
ID: 6450882
Thanks.

No I see that you do just like I have been doing, except
that you are using "Image" instead of "picture" as the first parameter to PaintPicture.

I was close but not enough.



0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
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…
Suggested Courses

719 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