Home All Groups Group Topic Archive Search About

imagelist and bitmaps

Author
1 Jul 2005 1:05 PM
Sam
Hi,
I've added two bitmaps to my project. Now I would like to create an
imagelist (in the code) and add those two images to it (so no path,
just the name). And I want those images to be compiled in the .dll.
This is a user control, so this why I want them to be embedded within
the dll.

Thx

Author
1 Jul 2005 1:13 PM
Robin Tucker
You don't need to add them to your project.  You can either add an imagelist
control to your form and add the images in the property editor of the
control; doing this will make them resources. Or you can right click on the
bmp file and compile it as an embedded resource - then get them at run-time.
I would recommend the former as it's a bit easier than flapping around with
embedded resources manually.


Show quoteHide quote
"Sam" <samuel.berthe***@voila.fr> wrote in message
news:1120223121.722969.220130@g47g2000cwa.googlegroups.com...
> Hi,
> I've added two bitmaps to my project. Now I would like to create an
> imagelist (in the code) and add those two images to it (so no path,
> just the name). And I want those images to be compiled in the .dll.
> This is a user control, so this why I want them to be embedded within
> the dll.
>
> Thx
>
Author
1 Jul 2005 1:16 PM
Peter Proost
Set the bitmaps build action to embedded resource and try this code to get
the image and load it in the imagelist:

Dim p As System.Reflection.Assembly
p = System.Reflection.Assembly.GetExecutingAssembly()
Dim img As New Bitmap(p.GetManifestResourceStream(Me.GetType(),
"envelop.jpg"))
ImageList1.Images.Add(img)

hth Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

Show quoteHide quote
"Sam" <samuel.berthe***@voila.fr> schreef in bericht
news:1120223121.722969.220130@g47g2000cwa.googlegroups.com...
> Hi,
> I've added two bitmaps to my project. Now I would like to create an
> imagelist (in the code) and add those two images to it (so no path,
> just the name). And I want those images to be compiled in the .dll.
> This is a user control, so this why I want them to be embedded within
> the dll.
>
> Thx
>
Author
1 Jul 2005 1:28 PM
Sam
Thx Peter, that seems to work!
Author
1 Jul 2005 1:35 PM
Peter Proost
Hi, I know it does, but I would also go for the first suggestion Robin made,
becauses it's more clear then getting things from the assembly

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

Show quoteHide quote
"Sam" <samuel.berthe***@voila.fr> schreef in bericht
news:1120224500.663588.107180@g47g2000cwa.googlegroups.com...
> Thx Peter, that seems to work!
>
Author
1 Jul 2005 2:32 PM
Sam
No, I can't just drag n drop an imagelist in my form : I don't have a
form! It's a user control inherited from Panel. Therefore I have to
hard-code everything myself. Your method is a better choice in that
case.

Thx
Author
1 Jul 2005 3:15 PM
Robin Tucker
You should be able to drag/drop an image list onto a user control - unless -
ahh, I see.  Was there a specific reason you derived from panel?

Show quoteHide quote
"Sam" <samuel.berthe***@voila.fr> wrote in message
news:1120228346.035540.214900@z14g2000cwz.googlegroups.com...
> No, I can't just drag n drop an imagelist in my form : I don't have a
> form! It's a user control inherited from Panel. Therefore I have to
> hard-code everything myself. Your method is a better choice in that
> case.
>
> Thx
>
Author
1 Jul 2005 3:36 PM
Sam
it's not even a user control, it's more like an inherited control. I've
just created my own personified docking panel. So in design mode there
is nothing to see.
Author
1 Jul 2005 3:18 PM
Sam
No, I can't just drag n drop an imagelist in my form : I don't have a
form! It's a user control inherited from Panel. Therefore I have to
hard-code everything myself. Your method is a better choice in that
case.

Thx
Author
1 Jul 2005 4:04 PM
Robin Tucker
Just out of interest - I've learnt to gather all my images in one place and
dynamically load them into a global singleton - similar to the way Peter
suggests.  The reason for this is because often many components share
images/icons and it's helps keep .exe size down if you share instances
(provided they don't get edited of course), rather than adding them at each
location.  Same for toolbar icons, which often are used in many
components/places.


Show quoteHide quote
"Sam" <samuel.berthe***@voila.fr> wrote in message
news:1120231083.453954.28960@o13g2000cwo.googlegroups.com...
> No, I can't just drag n drop an imagelist in my form : I don't have a
> form! It's a user control inherited from Panel. Therefore I have to
> hard-code everything myself. Your method is a better choice in that
> case.
>
> Thx
>