473,411 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

how to change the size of images in imagelist at runtime.

hai Anti Keskinen,
i have used
the following code MyListView->LargeImageList->ImageSize = gcnew
System::Drawing::Size(100,
100); // Sets large image size to 100, 100
here i am getting error like "gcnew is undeclared error",how to deeclare
'gcnew"
and when i am using in runtime to change the size of images in imagelist in
listview control in .net(forms application) by chnging one trckbar(like
tb1->Value),
the imagelist is disappearing,and if again i added images to that imagelist
the images r adding as currentimage size.
pls tell me how to change the size in runtime without destroying the images.
Thanks and Regards,
Sanjeev

Nov 17 '05 #1
2 8479
Hi Sanjeeva !

Please use the 'Reply Group' button of your news reader. It allows the chain
of messages to stay under the same topic, and following the discussion
becomes a whole lot easier.

Like I stated in my post, "gcnew" keyword is defined only in C++/CLI
context. This means that if you are using Visual Studio 2005 Beta, the
keyword will work and will do what it is supposed to do. In earlier
versions, it does not work, as C++/CLI is not supported yet.

What "gcnew" does is reserve memory for a new managed object on the heap. In
Managed C++, the equivalent is "new", I think. So, the call should look
like:

MyListView->LargeImageList->ImageSize = new System::Drawing::Size(100,100);

In the documentation, it says that when you set a new image size, the handle
is recreated. This means that you must order the listview to redraw itself.
If this does not work, then the only possibility is to create a copy of the
old imagelist with a new size property, then replace the old list, like
here: (This is Managed C++ code)

<snip starts>

// Somewhere at the begin of file, to avoid lots of typing
using System::Windows::Forms;

// Later in the file, where you need to change the imagelist size.
ImageList* pOldList = MyListView->LargeImageList;

ImageList* pNewList = new ImageList();
pNewList->ImageSize = new System::Drawing::Size(100, 100);
// Other setup for the new image list, like color depth and transparency, if
required.

IEnumerator* pOldListEnum = pOldList->Images->GetEnumerator();

pNewList->Images->Add( __try_cast<Bitmap*> (pOldListEnum->Current()) );

while ( pOldListEnum->MoveNext() )
pNewList->Images->Add( __try_cast<Bitmap*> (pOldListEnum->Current()) );

// The new image list is now a copy of the old one, with new image size set.
// Now we put it into the place of the old one
MyListView->LargeImageList = pNewList;

// The old one is discarded by the Garbage Collection at some point.

<snip ends>

I am not 100% certain that this approach will work. The idea is to create a
new imagelist, set a new size for it, and then systematically add the images
from the old list into the new list by using an enumerator to the old list.
Again, it is not certain whether ImageList::Images::Add will create a copy
of the image you add to it. This shouldn't make a difference in Managed C++,
though. However, it's a point that should be noted. So, do not use the code
snip blindly without examining it first, and debugging through it properly
to see if it REALLY works. I haven't tested it, so I do not know.

-Antti Keskinen
"Sanjeeva Reddy" <sanjeeva.reddy at yahoo no mail.com> wrote in message
news:Oc**************@TK2MSFTNGP10.phx.gbl...
hai Anti Keskinen,
i have used
the following code MyListView->LargeImageList->ImageSize = gcnew
System::Drawing::Size(100,
100); // Sets large image size to 100, 100
here i am getting error like "gcnew is undeclared error",how to deeclare
'gcnew"
and when i am using in runtime to change the size of images in imagelist
in
listview control in .net(forms application) by chnging one trckbar(like
tb1->Value),
the imagelist is disappearing,and if again i added images to that
imagelist
the images r adding as currentimage size.
pls tell me how to change the size in runtime without destroying the
images.
Thanks and Regards,
Sanjeev


Nov 17 '05 #2
hai Antti Keskinen,
i have used like that ,it worked partially,but the images r blinking and
getting blured.
can u give any suggestion for that.
and i am having some more doubts:
1)how to get the preview of movie file to add in imagelist(i mean the first
frame of movie file. )
here i am giving code for adding images in my imagelist below.
imageList1->Images->Add(Image::FromFile("C:\\ar1.jpg");
like that only i want to add my movie files(first frame) to my imagelist.
2)imagetransition:in imagetrancistion i want to use transition filter like
horizontalwipe(means we have to get the imagefrom left side) and
verticalwipe(means we have to get the image from top ) and alphablend.
Thanks&Regards
Sanjeev.
"Antti Keskinen" <an************@REMOVEME.ee.tpu.fi> wrote in message
news:O4**************@TK2MSFTNGP15.phx.gbl...
Hi Sanjeeva !

Please use the 'Reply Group' button of your news reader. It allows the chain of messages to stay under the same topic, and following the discussion
becomes a whole lot easier.

Like I stated in my post, "gcnew" keyword is defined only in C++/CLI
context. This means that if you are using Visual Studio 2005 Beta, the
keyword will work and will do what it is supposed to do. In earlier
versions, it does not work, as C++/CLI is not supported yet.

What "gcnew" does is reserve memory for a new managed object on the heap. In Managed C++, the equivalent is "new", I think. So, the call should look
like:

MyListView->LargeImageList->ImageSize = new System::Drawing::Size(100,100);
In the documentation, it says that when you set a new image size, the handle is recreated. This means that you must order the listview to redraw itself. If this does not work, then the only possibility is to create a copy of the old imagelist with a new size property, then replace the old list, like
here: (This is Managed C++ code)

<snip starts>

// Somewhere at the begin of file, to avoid lots of typing
using System::Windows::Forms;

// Later in the file, where you need to change the imagelist size.
ImageList* pOldList = MyListView->LargeImageList;

ImageList* pNewList = new ImageList();
pNewList->ImageSize = new System::Drawing::Size(100, 100);
// Other setup for the new image list, like color depth and transparency, if required.

IEnumerator* pOldListEnum = pOldList->Images->GetEnumerator();

pNewList->Images->Add( __try_cast<Bitmap*> (pOldListEnum->Current()) );

while ( pOldListEnum->MoveNext() )
pNewList->Images->Add( __try_cast<Bitmap*> (pOldListEnum->Current()) );
// The new image list is now a copy of the old one, with new image size set. // Now we put it into the place of the old one
MyListView->LargeImageList = pNewList;

// The old one is discarded by the Garbage Collection at some point.

<snip ends>

I am not 100% certain that this approach will work. The idea is to create a new imagelist, set a new size for it, and then systematically add the images from the old list into the new list by using an enumerator to the old list. Again, it is not certain whether ImageList::Images::Add will create a copy
of the image you add to it. This shouldn't make a difference in Managed C++, though. However, it's a point that should be noted. So, do not use the code snip blindly without examining it first, and debugging through it properly
to see if it REALLY works. I haven't tested it, so I do not know.

-Antti Keskinen
"Sanjeeva Reddy" <sanjeeva.reddy at yahoo no mail.com> wrote in message
news:Oc**************@TK2MSFTNGP10.phx.gbl...
hai Anti Keskinen,
i have used
the following code MyListView->LargeImageList->ImageSize = gcnew
System::Drawing::Size(100,
100); // Sets large image size to 100, 100
here i am getting error like "gcnew is undeclared error",how to deeclare
'gcnew"
and when i am using in runtime to change the size of images in imagelist
in
listview control in .net(forms application) by chnging one trckbar(like
tb1->Value),
the imagelist is disappearing,and if again i added images to that
imagelist
the images r adding as currentimage size.
pls tell me how to change the size in runtime without destroying the
images.
Thanks and Regards,
Sanjeev



Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Silvia | last post by:
Hi, I have a program that capture images and put this into a listview (using imagelist), the problem is when I delete de image the listview, when do that and capture another image, the image...
1
by: Anthony Boudouvas | last post by:
Hi to all, i have a treeview that i put some nodes in it with their repsective images. If i try to change the image and set it to some other ImageList index, nothing happens. The code i use...
3
by: Bruno Rodrigues | last post by:
Hi, Everytime I use a image in a Windows Form, Visual Studio.Net creates the image in the respective resx file. This can be very expensive in a project with about one hundred forms, where images...
2
by: A. Solomon | last post by:
Hi, I have a ImageList containing 4 bitmaps attached to a UserControl which acts as a Open/Close panel. This panel, upon click, switches the image in a PictureBox control to indicate the...
1
by: Sanjeeva Reddy | last post by:
hai, can u pls give me reply how to change the size of images in imagelist in vc++.net(in windows forms application).
3
by: Dean Slindee | last post by:
Probably easy, but the following does not work: Dim imgLarge As New ImageList imgLarge.ColorDepth = ColorDepth.Depth32Bit 'ok imgLarge.ImageSize(64, 64) 'nope imgLarge.ImageSize.Height...
7
by: Mitchell Vincent | last post by:
I've been trying to get a standard toolbar to play nice with some nice icons that I have. When I put them on a button or anything they look perfect, but through an imagelist and on a toolbar they...
0
by: Luis Arvayo | last post by:
Hi, When I add an image dynamically at runtime to an ImageList, the image is added but with the problem that all the images are added with black pixels surrounding them. Example code: ...
2
by: senfo | last post by:
I'm using an ImageList component in conjunction with a ListView control to display images and it appears as though it's only possible set the size of an image globally, for the entire list. Is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.