472,784 Members | 1,065 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 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 8324
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.