[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Pictures into pictureBox

Posted on 2000-01-05
12
Medium Priority
?
331 Views
Last Modified: 2010-05-02
Right then heres my problem.

I have a number of images which I would like to place into a picture box within a userControl. I want to know if anybody knows a way of loading these pictures into a picture box (more than one picture is going into one picture box).

 Speed is relatively important and so is the fact that the pictureBox retains it's autoRedraw = true property. I also need to draw boxes and text on top of the pictures and rearrange the pictures in minimum time.

I have tried this using BitBlt and memory DC's however the problem that I get does not allow me to create the picture in the picture box as an autoredraw image which is of no use to me.

What I need is either a work around on the problem I have or a different way to do it.

Help Please?
0
Comment
Question by:James_stillman
  • 4
  • 4
  • 2
  • +1
12 Comments
 
LVL 1

Expert Comment

by:Maximka
ID: 2325650
You can't do this straight with picturebox , but You can put image with index = 0 on PictureBox and when You need to put You pictures You just do that

 Load Image1(index)
 Set Image1(index).Picture = LoadPicture(MyPath)
 Image1(index).Left = x
 Image1(index).Top = y
 Image1(1).Visible = True

It will create new instances of Image1 and will place it on Your picturebox.
P.S. Don't forget to
  Unload Image1(index)
because VB don't free it untill end of application.
0
 
LVL 2

Expert Comment

by:adityau
ID: 2325684
Use Image controls for more than one images and place them at any place you want.
0
 
LVL 1

Expert Comment

by:Maximka
ID: 2325691
Thank You very much adityau ,but this is
exactly what I answered.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 2

Expert Comment

by:adityau
ID: 2325746
Yes Maximka. I know. I think both of us tried to give the solution at the same time and you gave it first. Which I did not see and gave the solution. But, after I commented, I saw that.
0
 
LVL 1

Author Comment

by:James_stillman
ID: 2326186
How can I reference the control array of the usercontrol from within a class module?
0
 
LVL 1

Expert Comment

by:Maximka
ID: 2326417
First of  all You can't , but if You
need it so You do something not right.
Try to look at You problem from other
side. Maybr it will help You:

Create Standard module and put into it
public sub that does
  Load Form1.Image1(index)

0
 
LVL 1

Expert Comment

by:Maximka
ID: 2326418
First of  all You can't , but if You
need it so You do something not right.
Try to look at You problem from other
side. Maybr it will help You:

Create Standard module and put into it
public sub that does
  Load Form1.Image1(index)

0
 
LVL 1

Author Comment

by:James_stillman
ID: 2326441
Yeah this is my problem the image control array will be placed upon a usercontrol and you cannot do what you have suggested from within a module within a usercontrol as the code would be:

load usercontrol.image1(index)

which is not allowed. And if I try to create a reference to the image1(0) object within a module I am not allowed either.

 And I don't want to access the control array from within the actual usercontrol's code.

Cheers
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 400 total points
ID: 2326657
Why not use the PaintPicture method?

Example using a standard exe:

Private pic1 As StdPicture
Private pic2 As StdPicture

Private Sub Form_Load()
    Picture1.AutoRedraw = True
    'Load some pictures
    'Use LoadResPicture if you have a resource
    'file added to the project and don't want to load from files.
    Set pic1 = LoadPicture("c:\windows\tiles.bmp")
    Set pic2 = LoadPicture("c:\windows\waves.bmp")
    UpdatePictures
End Sub

Private Sub UpdatePictures()
    'draw the pictures
    Picture1.PaintPicture pic1, 100, 100
    Picture1.PaintPicture pic2, 500, 500
End Sub

Private Sub Form_Unload(Cancel As Integer)
    'Clear the pictures
    Set pic1 = LoadPicture("")
    Set pic2 = LoadPicture("")
End Sub
0
 
LVL 1

Author Comment

by:James_stillman
ID: 2329374
Sorry Maximka but you were no help. Thankjs for your time but Erik37 Is the daddy and I will have to give him the points seen as he ansewered just what I wanted
0
 
LVL 1

Author Comment

by:James_stillman
ID: 2329384
Thank You Very Much
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2329666
You're welcome.  Glad to help.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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.
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…
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
Course of the Month11 days, 5 hours left to enroll

612 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