15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Customizing CListCtrl...

DIGITAL SURF -- 100343.1477@CompuServe.COM
Tuesday, July 30, 1996

Environment : Visual C++ 4.1, Win 95

I am using a CListCtrl to display some results. The list is used in the
LVS_REPORT mode because I want to use some columns. I also want to add bitmaps
before the text of each item. The problem is that I MUST display 64*64 bitmaps.
I'd like to know if I can use a CImageList to do that.

Any help will be appreciated.

Thanks in advance

Nicolas RAMPONI
DIGITAL SURF




Mike Blaszczak -- mikeblas@nwlink.com
Saturday, August 03, 1996

At 01:35 AM 7/30/96 EDT, DIGITAL SURF wrote:
>Environment : Visual C++ 4.1, Win 95

>I am using a CListCtrl to display some results. The list is used in the
>LVS_REPORT mode because I want to use some columns. I also want to add bitmaps
>before the text of each item. The problem is that I MUST display 64*64 bitmaps.
>I'd like to know if I can use a CImageList to do that.

You can't, inherently.  List controls can only directly support small icons,
large icons, or state images. None of these image types are 64x64 pixels in
size.

Your only alternative would be to make an owner-draw fixed image list.  You
can investigate the ROWLIST sample to get started with that.

>Thanks in advance

Buy me some new tennis racquets.  Thanks in advance.


.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.




ppbillc@srv2.sj.ablecom.net
Tuesday, August 06, 1996


>I am using a CListCtrl to display some results. The list is used in the
>LVS_REPORT mode because I want to use some columns. I also want to add bitmaps
>before the text of each item. The problem is that I MUST display 64*64 bitmaps.
>I'd like to know if I can use a CImageList to do that.

-You can't, inherently.  List controls can only directly support small icons,
-large icons, or state images. None of these image types are 64x64 pixels in
-size.

 hmm why wont this work?

CImageList *il  = new CImageList();
   il->Create(64,64,TRUE,1,1);
   il->Add( CBitmap* pbmImage, COLORREF crMask );

 where CBitmap is a 64x64 16 color bitmap

 Anyone for tennis?

B



 /    \
 *    *
\ _,-._/



Mike Blaszczak -- mikeblas@nwlink.com
Friday, August 09, 1996

At 02:52 PM 8/6/96 +0000, you wrote:
>
>>I am using a CListCtrl to display some results. The list is used in the
>>LVS_REPORT mode because I want to use some columns. I also want to add bitmaps
>>before the text of each item. The problem is that I MUST display 64*64
bitmaps.
>>I'd like to know if I can use a CImageList to do that.
>
>-You can't, inherently.  List controls can only directly support small icons,
>-large icons, or state images. None of these image types are 64x64 pixels in
>-size.
>
> hmm why wont this work?
>
>CImageList *il  = new CImageList();
>   il->Create(64,64,TRUE,1,1);
>   il->Add( CBitmap* pbmImage, COLORREF crMask );
>
> where CBitmap is a 64x64 16 color bitmap

That'll work in that it compiles and runs without error.  But
it doesn't work because it has nothing to do with a list view
control.  You've just, independently of any control at all,
created an image list and slapped a bitmap on it.

If you want to finish writing code in response to the question,
you'll need to associate that image list with the list view.
To do that, you'll need to call CListView::SetImageList(). That
function takes an enum which indicates the size of the images:

LVSIL_NORMAL    Image list with large icons.
LVSIL_SMALL     Image list with small icons.
LVSIL_STATE     Image list with state images.

none of these are the same size as 64-by-64 pixels.  I don't
think the list view control is prepared to paint and lay out
bitmaps of an arbitrary size: it works with only these three.

> Anyone for tennis?

It's surprising that beer cans don't fall out of my pockets when I run.

.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.




R.H.J. Geraets -- R.Geraets@Ehv.Tass.Philips.Com
Tuesday, August 13, 1996

[Mini-digest: 2 responses]

Hey Mike,

I think we have found an area where a lister can actually teach you something!
(isn't that  nice ;-)

A CListcontrol object will accept and correctly draw these images.
I myself am using several list controls that hold images of 64x48 pixels
(using LVSIL_NORMAL).
No problems here.

(Although I must admit I have not succeeded in using more than 16 colors
for these images, I guess more than the 16 standard windows colors will cause
problems on 256 color displays).

Bye,


Rene' Geraets


-----From: Lev Gloukhenki 

Definitely not right ! First of all, code like this works fine (I checked it
with CListView object, but I believe that there is no problem  with the
"pure" CListCtrl ).

int MylistView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
 lpCreateStruct->style |= ( LVS_ICON | LVS_AUTOARRANGE );
 bool res = m_ctlImage.Create(IDB_BITMAP1, 64 ,0,RGB(0,132,132));
                                           ^
 m_ctlImage.SetBkColor(GetSysColor(COLOR_WINDOW));

 if (CListView::OnCreate(lpCreateStruct) == -1)
		return -1;
 GetListCtrl().SetImageList(&m_ctlImage, LVSIL_NORMAL );
	
 return 0;

} // MylistView::OnCreate

IDB_BITMAP1 is a  64x640 pixels bitmap ( contains 10  64x64 icons )
m_ctlImage is a CListView-derived class member of type CImageList

The second : here is the fragment from Microsoft's COMMCTRL.H :

#define LVSIL_NORMAL            0
#define LVSIL_SMALL             1
#define LVSIL_STATE             2

Preprocessor definitions ( not enum ) LVSIL_NORMAL, LVSIL_SMALL, LVSIL_STATE  
do not define icon sizes at all. You just can assosiate with control up to
three ImageLists,one of each type ( with arbitrary size of  bitmap, that
must be defined as the second parameter in CImageList::Create() ), and they
will be selected according to current control style - LVSIL_NORMAL for
LVS_ICON, LVSIL_SMALL for LVS_SMALLICON, etc.

The third : There is no member function of CListView::SetImageList(). 
                                            ^^^^^^^^^ 

Gloukhenki Lev.
Shira Computers Ltd.
lev@shira.co.il





Mike Blaszczak -- mikeblas@nwlink.com
Wednesday, August 14, 1996

At 09:31 AM 8/13/96 +0200, you wrote:

>I think we have found an area where a lister can actually teach you something!

I'm certainly not above that.  After all the questions I've tirelessly answered
here, I'd have to get a few wrong sometime.

>A CListcontrol object will accept and correctly draw these images.
>I myself am using several list controls that hold images of 64x48 pixels
>(using LVSIL_NORMAL).
>No problems here.

Groovy: I'm glad it works out.  This certainly didn't work when I last
tried it, which was probably back in the Windows 95 beta.
I can't remember which icon type I tried it with, but the control didn't
draw anything unless the size I set was exactly equal to the GetSystemMetrics()
dimensions for the corresponding icon style.

.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.





| Вернуться в корень Архива |