icons and bitmap files not found in 2002

  • Thread starter Richard Lewis Haggard
  • Start date
R

Richard Lewis Haggard

I'm developing in C#. When my app is deployed to either the emulator or my
little iPAQ running 2002, there are problems with the application finding
bitmaps and icons. Obviously, I'm doing something wrong but what?

For example, I make a dialog box that has a picture control. The picture is
associated with a bitmap. At runtime, the picture control fails to find its
bitmap file and throws an exception. I'm assuming that the reason that the
application is not displaying an icon is because of much the same sort of
problem.

So - what do I need to do in order for the picture controls and icons to
properly load their associated bitmaps?
 
J

James McCutcheon

The problem is that the referenced images arent automatically passed to the
device/emulator.

There are two ways to solve this problem:

1. Code the path the image is going to be and distribute via cab the image
to that location.

OR

2. embed the image into the build. To do this simply go to your project
explorer and "Add existing Item" select your image, then go to the
properties tab for that image and change "build action" to "Embedded
Resource". Then via code you can call your image via
Image backgroundImage = new
Bitmap(Assembly.GetExecutingAssembly).GetManifestResourceStream("myproject.m
ybitmap.bmp"));

this.pictureBox1.Image = backgroundImage;

where myproject is the name of your assembly.

more info can be found at
http://samples.gotdotnet.com/quickstart/CompactFramework/doc/bkgndimage.aspx
 
R

Richard Lewis Haggard

That's much better, thank you. I'm getting the bitmaps into the picturebox
controls now but the icon is still failing.

It turns out that, unlike previous versions of the development environment,
just because you've added an icon to the project, that doesn't necessarily
mean that the icon is going to be the default icon for the application. Once
I realized this and went to the project objects/General tab and specified
the icon to use, I had assumed that it would work. Close but no cigar. There
is now an icon being displayed but it isn't the one that I created. It looks
like a white rectangle with a black border, the upper right corner folded
down and six smaller rectangles inside of it. I'm assuming that this is some
sort of default icon that I've never seen before.

So, how do I get my own icon to show?
=======
Richard Lewis Haggard

James McCutcheon said:
The problem is that the referenced images arent automatically passed to the
device/emulator.

There are two ways to solve this problem:

1. Code the path the image is going to be and distribute via cab the image
to that location.

OR

2. embed the image into the build. To do this simply go to your project
explorer and "Add existing Item" select your image, then go to the
properties tab for that image and change "build action" to "Embedded
Resource". Then via code you can call your image via
Image backgroundImage = new
Bitmap(Assembly.GetExecutingAssembly).GetManifestResourceStream("myproject.m
ybitmap.bmp"));

this.pictureBox1.Image = backgroundImage;

where myproject is the name of your assembly.

more info can be found at
http://samples.gotdotnet.com/quickstart/CompactFramework/doc/bkgndimage.aspx
 
J

James McCutcheon

Richard,

You have to make sure that there is a 16x16 version of the icon, then embed
this as a resource. Make sure the Application Icon path of the Project is
pointing to this, sometimes it doesnt reset this, I do a bit of voodoo
coding here by pointing to a different icon and back to the correct one
making sure visual studio isnt thinking it knows better than me.

--
James McCutcheon
Blog: http://www.j3technology.com/blog


Richard Lewis Haggard said:
That's much better, thank you. I'm getting the bitmaps into the picturebox
controls now but the icon is still failing.

It turns out that, unlike previous versions of the development environment,
just because you've added an icon to the project, that doesn't necessarily
mean that the icon is going to be the default icon for the application. Once
I realized this and went to the project objects/General tab and specified
the icon to use, I had assumed that it would work. Close but no cigar. There
is now an icon being displayed but it isn't the one that I created. It looks
like a white rectangle with a black border, the upper right corner folded
down and six smaller rectangles inside of it. I'm assuming that this is some
sort of default icon that I've never seen before.

So, how do I get my own icon to show?
=======
Richard Lewis Haggard

James McCutcheon said:
The problem is that the referenced images arent automatically passed to the
device/emulator.

There are two ways to solve this problem:

1. Code the path the image is going to be and distribute via cab the image
to that location.

OR

2. embed the image into the build. To do this simply go to your project
explorer and "Add existing Item" select your image, then go to the
properties tab for that image and change "build action" to "Embedded
Resource". Then via code you can call your image via
Image backgroundImage = new
Bitmap(Assembly.GetExecutingAssembly).GetManifestResourceStream("myproject.m
ybitmap.bmp"));

this.pictureBox1.Image = backgroundImage;

where myproject is the name of your assembly.

more info can be found at
http://samples.gotdotnet.com/quickstart/CompactFramework/doc/bkgndimage.aspx or
 
C

Chris Tacke, eMVP

The PPC caches icons, so you probably need to soft-reset the device.

-Chris


Richard Lewis Haggard said:
That's much better, thank you. I'm getting the bitmaps into the picturebox
controls now but the icon is still failing.

It turns out that, unlike previous versions of the development environment,
just because you've added an icon to the project, that doesn't necessarily
mean that the icon is going to be the default icon for the application. Once
I realized this and went to the project objects/General tab and specified
the icon to use, I had assumed that it would work. Close but no cigar. There
is now an icon being displayed but it isn't the one that I created. It looks
like a white rectangle with a black border, the upper right corner folded
down and six smaller rectangles inside of it. I'm assuming that this is some
sort of default icon that I've never seen before.

So, how do I get my own icon to show?
=======
Richard Lewis Haggard

James McCutcheon said:
The problem is that the referenced images arent automatically passed to the
device/emulator.

There are two ways to solve this problem:

1. Code the path the image is going to be and distribute via cab the image
to that location.

OR

2. embed the image into the build. To do this simply go to your project
explorer and "Add existing Item" select your image, then go to the
properties tab for that image and change "build action" to "Embedded
Resource". Then via code you can call your image via
Image backgroundImage = new
Bitmap(Assembly.GetExecutingAssembly).GetManifestResourceStream("myproject.m
ybitmap.bmp"));

this.pictureBox1.Image = backgroundImage;

where myproject is the name of your assembly.

more info can be found at
http://samples.gotdotnet.com/quickstart/CompactFramework/doc/bkgndimage.aspx or
 
R

Richard Lewis Haggard

No joy. Application icon is still not showing in the Pocket PC's File
Explorer on the top caption bar.

In the Solution Explorer, I have spider.ico which has been set to Build
Action = Embedded Resource.
In the main form's CS file, I changed the icon load from its default $icon
stuff to

this.Icon = new System.Drawing.Icon(
Assembly.GetExecutingAssembly().GetManifestResourceStream("Pocket_Spider.Spi
der.ico") );

And, of course, in order to get the reference to 'Assembly', I added

using System.Reflection

to the top of the module.

No change.

As per another response, I did a soft reset. No change.

So, there's still something not right. Suggestions?
========
Richard Lewis Haggard
 

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