473,883 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

hai Anti Keskinen,
i have used
the following code MyListView->LargeImageLi st->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,an d 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 8542
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->LargeImageLi st->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<Bitm ap*> (pOldListEnum->Current()) );

while ( pOldListEnum->MoveNext() )
pNewList->Images->Add( __try_cast<Bitm ap*> (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->LargeImageLi st = 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::Imag es::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.red dy at yahoo no mail.com> wrote in message
news:Oc******** ******@TK2MSFTN GP10.phx.gbl...
hai Anti Keskinen,
i have used
the following code MyListView->LargeImageLi st->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,an d 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::Fro mFile("C:\\ar1. jpg");
like that only i want to add my movie files(first frame) to my imagelist.
2)imagetransiti on:in imagetrancistio n i want to use transition filter like
horizontalwipe( means we have to get the imagefrom left side) and
verticalwipe(me ans we have to get the image from top ) and alphablend.
Thanks&Regards
Sanjeev.
"Antti Keskinen" <an************ @REMOVEME.ee.tp u.fi> wrote in message
news:O4******** ******@TK2MSFTN GP15.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->LargeImageLi st->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<Bitm ap*> (pOldListEnum->Current()) );

while ( pOldListEnum->MoveNext() )
pNewList->Images->Add( __try_cast<Bitm ap*> (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->LargeImageLi st = 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::Imag es::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.red dy at yahoo no mail.com> wrote in message
news:Oc******** ******@TK2MSFTN GP10.phx.gbl...
hai Anti Keskinen,
i have used
the following code MyListView->LargeImageLi st->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,an d 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
1929
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 painting in the listview is the image delete, I supose that the problem is that the image exist in the imagelist, in order to solve this problem I clear the imagelist and add all the images captured, but i have another problem now, some time when I...
1
16885
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 is: private void ChangeServantStatus(string servant, ServantStatus status) {
3
3784
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 of delete, insert and update (for example) appear several times. The only way I found to optimize this is creating a Windows Form with a ImageList with all images, and inherit every form from this one. But then I would be loading in memory all...
2
3211
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 current panel status (Open/Close). Problem is that in certain complex scenarios the images disappear! from the ImageList. That is, when I call: imageList.Images, I get
1
1204
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
5637
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 = 64 'nope, get property only
7
2947
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 all have this blue aura around them. I assume that is from the transparency, but I don't understand why almost any other control displays them properly.. There really is no replacement for the toolbar (without paying!), so I hope someone can tell...
0
1407
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: for(int i = 0; i < openFileDialog1.FileNames.Length; i++) {
2
3225
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 there any way to adjust the size of images on a per image basis? Thank you, -- Sean
0
9944
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11151
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10752
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10420
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7974
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5996
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4619
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3238
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.