Adding images to a listview

M

Markus.Humm

Hello,

I'm using CF 1.0 and neither VB.net nor C# as programming environment.
My application does its job so far but now I want to add icons to a
ListView.

I created two bitmaps by code and a ImageList (also by code, can't use a
designer here) and added the two bitmaps.

I assigned the ImageList to the ListView (both: Small and LargeImages)
and set the ImageIndex of some ListViewItem to 0 (my first image in the
ListView). I get a NullReferenceObject or similar exception. My ListView
is set to contain 2 columns.

What's causing the exception and how to solve it?
No, I don't want to use VB.net or C#...

Greetings

Markus
 
G

Guest

Well since the CF only supports C# and VB this implies that you are hacking
in with some other unsupported language - maybe managed C++. How do you
know you're not getting some IL that's not supported by the CF that's
causing grief? Giving us a general description of what you're doing
without code for us to see what you're _actually_ doing is not very useful.

Have you tried the same operation with C# or VB? Does it work there? Using
the same bitmaps? How does the generated IL compare?
 
M

Markus.Humm

Well since the CF only supports C# and VB this implies that you are hacking

Who says this? Microsoft? (I don't want to insult you I simply want to
state that MS is a bit shortsighted for CF development and only looking
on their own tools and event them not fully [Managed C++ and J++ being
left alone])

I'm using Delphi 2006 with the included CF compiler. For all other stuff
I tried it worked seemingly well (at least well enough).
in with some other unsupported language - maybe managed C++. How do you
know you're not getting some IL that's not supported by the CF that's
causing grief?

I don't think so. Afaik it's simply calling the right classes within the
CF. I already show a bitmap somewhere else in the application and this
works. The bitmaps used are located as BMP-files in the application's
directory.
Giving us a general description of what you're doing
without code for us to see what you're _actually_ doing is not very useful.

Okay, I will give code later on. Just some minutes (there is something
more urgent for my right now).
Have you tried the same operation with C# or VB? Does it work there? Using
the same bitmaps? How does the generated IL compare?

No, because I either had to buy them or install some trials which just
occupy too much space when you're normally developping with Delphi and
this already contains a compiler for CF. But I see your point.
Technically I just can't do this right now.

Greetings

Markus
 
P

Paul G. Tobey [eMVP]

Yes, Microsoft says it. Managed C++ is *NOT SUPPORTED* for use with .NET
Compact Framework. It would be possible for Delphi to generate correct code
for the .NET CF, but, given the size of that market versus the size of the
desktop market, I'm pretty sure that they haven't put *any* effort into
that.

Paul T.

Markus.Humm said:
Well since the CF only supports C# and VB this implies that you are
hacking

Who says this? Microsoft? (I don't want to insult you I simply want to
state that MS is a bit shortsighted for CF development and only looking on
their own tools and event them not fully [Managed C++ and J++ being left
alone])

I'm using Delphi 2006 with the included CF compiler. For all other stuff I
tried it worked seemingly well (at least well enough).
in with some other unsupported language - maybe managed C++. How do you
know you're not getting some IL that's not supported by the CF that's
causing grief?

I don't think so. Afaik it's simply calling the right classes within the
CF. I already show a bitmap somewhere else in the application and this
works. The bitmaps used are located as BMP-files in the application's
directory.
Giving us a general description of what you're doing without code for us
to see what you're _actually_ doing is not very useful.

Okay, I will give code later on. Just some minutes (there is something
more urgent for my right now).
Have you tried the same operation with C# or VB? Does it work there?
Using the same bitmaps? How does the generated IL compare?

No, because I either had to buy them or install some trials which just
occupy too much space when you're normally developping with Delphi and
this already contains a compiler for CF. But I see your point. Technically
I just can't do this right now.

Greetings

Markus
 
M

Markus.Humm

Hello,

here is the proposed source code:

The bitmaps and imagelist are created in the Load event:

bitmap1:=Bitmap.Create('\temp\folder_closed16.bmp');
bitmap2:=Bitmap.Create('\temp\new_document16.bmp');

il_small:=ImageList.Create;
il_small.Images.Add(bitmap1);
il_small.Images.Add(bitmap2);
mylv.LargeImageList:=il_small;
mylv.SmallImageList:=il_small;


When the ImageListItems are added it looks like this:
Where item is a ImageListItem (okay, you guessed that already
I suppose...)

item:=ListViewItem.Create('some item...');
item.ImageIndex:=0;
item.SubItems.Add('some subitem...');
mylv.Items.Add(item);

It also doesn't help to set the width and height of the imagelist to 16
each (size of these icons) or to set the item.imagelist to il_small and
set the size there...simply doesn't help.

If I leave the icons out the form works as it should, so these icons are
just a visual gimmic, but a helpfull one...

Greetings

Markus
 
M

Markus.Humm

Paul said:
Yes, Microsoft says it. Managed C++ is *NOT SUPPORTED* for use with .NET
Compact Framework. It would be possible for Delphi to generate correct code
for the .NET CF, but, given the size of that market versus the size of the
desktop market, I'm pretty sure that they haven't put *any* effort into
that.
You may want to research the current abilities of Delphi!
For Delphi 2005 there was a time limited compiler preview available,
this contained some bugs but was useable in the first place with some
setup work and manual work etc.

In D2006 the compiler was officially included and the bugs have been
fixed. There is a freeware addon which integrates it in the IDE and
removes all stuff the normal visual .NET designer creates which is not
supported on CF so it compiles agains the CF assemblies. It can also
launch the standalone MS emulator and copy the application to the shared
folder. Borland additionally ships some libraries targeted towards CF so
saying the didn't put in any effort is a big understatement...

Okay, there are still some things missing, e.g. a debugger.

Greetings

Markus
 
G

Guest

I'm not a Delphi programmer, but the code looks right.

What's the color depth of the bitmaps? Try 256 color to see what happens
(I'm not sayig greater depth isn't supported, but it's worth ruling out, as
I can't say I've ever tried it).

-Chris
 
M

Markus.Humm

I'm not a Delphi programmer, but the code looks right.

What's the color depth of the bitmaps? Try 256 color to see what happens
(I'm not sayig greater depth isn't supported, but it's worth ruling out, as
I can't say I've ever tried it).
Okay, will look into that. Could be (even if I doubt it but's worth the
try).

Greetings

Markus
 
M

Markus.Humm

Simon said:
I've used Delphi at my last company and the .NET support was terrible.

Half the features were missing and it was buggy as ever. I have also used
other "third party" products and languages that target .NET and they are
equally bad. I don't want to mention their names hear as their is no need,
but if you want to truely experience .NET CF or desktop version in their true
great form, you need to use Microsoft languages and tools. How can you expect
to develop a first class product today without a debugger!

Third party vendors simply cannot keep up the pace with Microsoft. Now we
have .NET 3 WinFX for Vista, you will probebly find many third party's have
barely touched the surface for .NET 2 support let alone even think about
Vista and WinFX.

But MS also does screw up things in my eyes: I#ve been reported that a
200 MB SP1 for VS2005 needs several GB of free HDD space and will run
for several hours!

So it might just be that M$ is driving too fast loosing some reality
sense on the road while they go...

And: you didn't tell which version of Delphi you used. I agree that 2005
was terrible (I don't do .NET except for CF) but 2006 has been some
improvement in many ways (stability, startup etc.)

Greetings

Markus
 
P

Paul G. Tobey [eMVP]

Either might be the right tool for the job, depending on what the job is.
However, trying to use a hammer to remove a bolt, instead of a wrench, or a
screwdriver to pound in nails, while it might eventually work, is always a
waste of time. If you always feel like, if there's programming to be done,
I've got to use Delphi, you're going to get stuck using the wrong tool for
the job, as you are now. Your entire thread on the exception business, of
something like 20 messages, would have been completely unnecessary if you
had used the right tool for the job.

I'm not going to speculate, based on random rumor, what VS2005 SP1 is going
to look like and who cares anyway? It's an update. If everything in VS2005
gets freshened and improved by the update, why is that bad? It might be bad
that the improvements were needed at all, but I find it hard to complain
that a large number of problems are being fixed.

Paul T.
 
M

Markus.Humm

Paul G. Tobey [eMVP] schrieb:

[snip]
I'm not going to speculate, based on random rumor, what VS2005 SP1 is going
to look like and who cares anyway? It's an update. If everything in VS2005
gets freshened and improved by the update, why is that bad? It might be bad
that the improvements were needed at all, but I find it hard to complain
that a large number of problems are being fixed.
I don't complain about fixing bugs or something like this but rater the
hardware and time requirements for applying the fix! It's rediculous in
my eyes that applying the fix will need several gigabytes of temporary
storage space and several hours of processing. That is my point.

Greetings

Markus
 
M

Markus.Humm

I'm not a Delphi programmer, but the code looks right.

What's the color depth of the bitmaps? Try 256 color to see what happens
(I'm not sayig greater depth isn't supported, but it's worth ruling out, as
I can't say I've ever tried it).

Tried it, but no succes either. But since it's a visual gimmic mor or
less I put it aside for now.

Greetings

Markus
 

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

Similar Threads


Top