create dynamic thumbnails on form or pannel using a picturebox?

G

Guest

Hello,

I want to simulate the dynamic thumbnail display of Windows Explorer (winxp)
on a form or pannel container. If I place a picture box on my container
form/pannel and dimension it to the size of a thumbnail and set the sizemode
to Stretch -- I get one thumbnail. I want to retrieve all the picture files
(jpg, bmp) in a directory into an array list and then display this list as
thumbnails on my form dynamically. So my question is "how do I create
thumbnails on the fly"? I am thinking - copy the picturebox at runtime as
many times as I need. Am I on the right track here? Or is there a more
efficient/correct way to do this? If I have to copy the picturebox at
runtime - how is this accomplished?

Thanks,
Rich
 
G

Guest

Would a datagrid be an option? I could create the datagrid on the fly and
have an image column(s). Any suggestions appreciated.
 
G

Guest

Not sure I understand exactly your question but you can create a thumbnail
image from an image using the GetThumNailImage method for Images;

'Assume MyImage is your image (bitmap, etc)
'Dim inp As New IntPtr
'Try
' If Height > 0 AndAlso Width > 0 Then
' MyThumbImage = myImage.GetThumbnailImage(Height, Width, Nothing, inp)
' Else
' Return Nothing
' End If
'Catch er As Exception
' Return Nothing
'End Try
'Convert to Bitmap if desired
'Return CType(MyThumbImage, Bitmap)
 
G

Guest

Thanks for your reply. Yes, I did find a sample of the code you show for
creating a thumbnail in a picturebox control. What I want to do is to
display multiple thumbnails in a container like a form or pannel - similar to
Windows Explorer when you select View Thumbnails for a list of jpg or bmp
files in a directory. Is it possible to dynamically create multiple picture
boxes on a form/pannel at run time? How is this accomplished? For example,
I retrieve a list of jpg/bmp files from a directory into an arraylist. Say
there are 5 picture files. I want to display all 5 pictures as thumbnails on
my container. Then say I retrieve a list of picture files from another
directory - say 20 pictures. I want to display those 20 pictures as
thumbnails on my form/pannel.

Thanks,
Rich
 
M

Mark

Rich said:
Thanks for your reply. Yes, I did find a sample of the code you show for
creating a thumbnail in a picturebox control. What I want to do is to
display multiple thumbnails in a container like a form or pannel - similar to
Windows Explorer when you select View Thumbnails for a list of jpg or bmp
files in a directory. Is it possible to dynamically create multiple picture
boxes on a form/pannel at run time? How is this accomplished? For example,
I retrieve a list of jpg/bmp files from a directory into an arraylist. Say
there are 5 picture files. I want to display all 5 pictures as thumbnails on
my container. Then say I retrieve a list of picture files from another
directory - say 20 pictures. I want to display those 20 pictures as
thumbnails on my form/pannel.

Thanks,
Rich

This link might be helpful to you http://tinyurl.com/cfds2.
 
G

Guest

Thanks. That was a useful example. I will have to study it for a while to
see if I can incorporate (figure out how the controls are created) it into my
app.

Thanks again,
Rich
 
G

Guest

You can either create the picture boxes on your form at design time then set
the visible property to True for the ones you want to show or you can create
and dispose of them at designtime; To create a picture box at run time;

dim pic1 as new PIctureBox
Me.Controls.Add(pic1)
pic1.Width = xxx
pic1.Height = xxx
pic1.Top=xxx
pic1.Left = yyy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top