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

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


Changing TextItem color in a ListView

elie e.e. bensaci -- ebensaci@nortel.ca
Tuesday, October 15, 1996

Hello there,

Environment:MS Visual C++ 4.1, Windows 95

How can I change the text color of an Item in a ListView, Only one specific item. Not all 
the text (items ) in the ListView.

I've tried SetTextColor( COLORREF cr), but this member function will change the entire 
text to cr color, I do not want to perform this task, I want only to change the text 
color of a specific text item.

Did someone have an answer!

Someone suggest to me to use the LVS_OWNERDRAWFIXED style when my list is created 
combined with an LVS_REPORT, but which member function I have to use to Draw my items???

Microsoft Help (book on line)says:
=================================
LVS_OWNERDRAWFIXED: Enables the owner window to paint items in report view. The list view 
control sends a WM_DRAWITEM message to paint each item; it does not send separate 
messages for each subitem. The itemData member of the DRAWITEMSTRUCT structure contains 
the item data for the specified list view item.

Thanks guys.

Elie



Isaac Katzenelson -- isaac_k@goldnet.net.il
Thursday, October 17, 1996

[Mini-digest: 3 responses]

elie (e.e.) bensaci wrote:
> 
> Hello there,
> 
> Environment:MS Visual C++ 4.1, Windows 95
> 
> How can I change the text color of an Item in a ListView, Only one specific item. Not all
> the text (items ) in the ListView.
> 
> I've tried SetTextColor( COLORREF cr), but this member function will change the entire
> text to cr color, I do not want to perform this task, I want only to change the text
> color of a specific text item.
> 
> Did someone have an answer!
> 
> Someone suggest to me to use the LVS_OWNERDRAWFIXED style when my list is created
> combined with an LVS_REPORT, but which member function I have to use to Draw my items???
> 
> Microsoft Help (book on line)says:
> =================================
> LVS_OWNERDRAWFIXED: Enables the owner window to paint items in report view. The list view
> control sends a WM_DRAWITEM message to paint each item; it does not send separate
> messages for each subitem. The itemData member of the DRAWITEMSTRUCT structure contains
> the item data for the specified list view item.
> 
> Thanks guys.
> 
> Elie

Hi Elie,

Your qestion was : but which member function I have to use to Draw my
items???
I think that there is no predefined member function for this.
Use classwizard to create function for WM_DRAWITEM message in your
dialog class.

Regards,
Isaac.

_____________________________________________________________________________________
LOOSE WEIGHT NOW ASK ME HOW !!!
_____________________________________________________________________________________
-----From: Kevin L McCarthy 

Please check out the "rowlist" sample on the MFC CD. 
I found this by using a help "query" on "CListView", and looking for titles 
about samples.

Kevin
-----From: drt@ebt.com (Randy Taylor)

look for the ODLIST.ZIP (OwnerDrawList) sample
of Microsoft's WebSite.

You need to provide a member function and
message map entry for the WM_DRAWITEM message
and you must draw all of the items,
even if want just one item to have different
text than the other items.







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