Solved

Copying picture boxes

Posted on 2001-07-24
17
158 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
  • 6
  • 3
  • 3
  • +3
17 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
Comment Utility
Try this...

Set Picture2 = Picture1
0
 
LVL 18

Author Comment

by:Crash2100
Comment Utility
still does the same thing
0
 
LVL 38

Expert Comment

by:PaulHews
Comment Utility
Set AutoRedraw = True on both picture boxes.
0
 
LVL 6

Expert Comment

by:JonFish85
Comment Utility
try something like:

Picture2.PaintPicture Picture1.Picture
0
 
LVL 38

Expert Comment

by:PaulHews
Comment Utility
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 27

Expert Comment

by:Ark
Comment Utility
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
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 22

Expert Comment

by:rspahitz
Comment Utility
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
Comment Utility
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
Comment Utility
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 27

Accepted Solution

by:
Ark earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 27

Expert Comment

by:Ark
Comment Utility
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
Comment Utility
thanks for all the help!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

771 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