[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Copying picture boxes

Posted on 2001-07-24
17
Medium Priority
?
166 Views
Last Modified: 2010-05-02
When I use something like Picture1.Line to make a line in a picturebox, and then I try to copy the contents of Picture1, to an icon or to Picture2, using Picture2.Picture = Picture1.Picture.  Why is it that the line I just made isn't copied?  Is there some other method I should be using instead of picture2=picture1?
0
Comment
Question by:Crash2100
[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
  • 6
  • 3
  • 3
  • +3
17 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6315018
Try this...

Set Picture2 = Picture1
0
 
LVL 18

Author Comment

by:Crash2100
ID: 6315060
still does the same thing
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6315204
Set AutoRedraw = True on both picture boxes.
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 6

Expert Comment

by:JonFish85
ID: 6315207
try something like:

Picture2.PaintPicture Picture1.Picture
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6315225
Private Sub Command1_Click()
    Picture1.AutoRedraw = True
    Picture2.AutoRedraw = True
    Picture1.Line (0, 0)-(Picture1.ScaleWidth, Picture1.ScaleHeight)
    Set Picture2.Picture = Picture1.Image
    Picture2.Refresh
End Sub
0
 
LVL 28

Expert Comment

by:Ark
ID: 6315278
Hi
Just to explain:
When you use Picture1=Picture2 you use default property (Picture1.Picture = Picture2.Picture)
Picture property is what you set at design time and/or explicity set at run time. All your drawings store in .Image property.
So, you need

   Set Picture2.Picture = Picture1.Image
or
   Set Picture1.Picture = Picture1.Image
   Picture2 = Picture1

Cheers
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6315282
PaulHews seems to be correct.  The difference is in using the "image" property of the picturebox (which holds the current image) rather than the "picture" property (which holds a reference to a memory location that holds the image.)

It seems silly that only one works and not the other, but that's how it works sometimes.
0
 
LVL 18

Author Comment

by:Crash2100
ID: 6315306
ok, I see how I can copy the contents of picture1 to picture2.  How would I go about copying the contents of Picture1 to the icon of the form.  Because when I try something like below I get the error "Invalid property value."
 Picture1.Circle (0, 0), 500
 Picture1.Picture = Picture1.Image
 Me.Icon = Picture1.Picture
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6315317
You'll nice that if you go to that property and try to load an icon from windows, your only selections are .ico and .cur types, not bitmaps.

I think you need to save the bitmap image as an icon, then try loading it in.
0
 
LVL 18

Author Comment

by:Crash2100
ID: 6315369
so there's no way I can somehow create an icon from within visual basic?  the main reason I wanted to do this is so I could create an animated icon for my form.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6315411
Well, I'm not sure, but if you make the bitmap no more than 32x32 and save it with an .ico extension, it make actually work.  It still saves it as a bitmap, but Windows seems to recognize this as a cheap knock-off icon.
0
 
LVL 28

Accepted Solution

by:
Ark earned 200 total points
ID: 6315415
Hi
Add ImageList to your form:

Private Sub Command1_Click()
  Picture1.AutoRedraw = True
  Picture1.Line (0, 0)-(Picture1.Width, Picture1.Height)
  ImageList1.ListImages.Clear
  ImageList1.ListImages.Add , , Picture1.Image
  Set Icon = ImageList1.ListImages(1).ExtractIcon
End Sub

Cheers
0
 
LVL 18

Author Comment

by:Crash2100
ID: 6315416
I know if you save it as a .ico that it will recognize it as an icon, but I would prefer to not have to save the files (if possible), just to dynamically create the picture in the program and immediately put it up in the form's icon.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 6315489
I thought this was about copying picture boxes, but it's actually about copying icons?  Ark has the answer there for you.
0
 
LVL 18

Author Comment

by:Crash2100
ID: 6315657
Ark, sorry, I didn't notice your comment the first time.  So, the only way to get my picture to the icon, is to first put it into an image list?  If so, why is this?
0
 
LVL 28

Expert Comment

by:Ark
ID: 6315681
Icon and Bitmap format are different. Form.Icon property accept only Icons.
There is an API way to convert bitmap to Icon, but it's long and hard. The easiest way is to use ImageList.

Cheers
0
 
LVL 18

Author Comment

by:Crash2100
ID: 6319578
thanks for all the help!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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.
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…
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

650 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