Solved

Using PaintPicture without any Picture

Posted on 2001-09-03
6
485 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
  • 3
  • 2
6 Comments
 
LVL 49

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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 200 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

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

10 Experts available now in Live!

Get 1:1 Help Now