Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using PaintPicture without any Picture

Posted on 2001-09-03
6
Medium Priority
?
544 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 54

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
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…
Suggested Courses

972 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