473,382 Members | 1,396 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,382 software developers and data experts.

I need help, please

Geo
Hi,

I'm using a List Control (report view) in a dialog. This
list displays 4 text items, each consisting of 3 columns.
Let's consider the following example:

Title of column1 Title c2 Title c3 Title c4
Item1 info12 info13 info14
Item2 info22 info23 info24
Item3 info32 info33 info34
Item4 info42 info43 info44

I want to change the text color of an item if a cetain
condition is true. In the example above, say I want to
change the color of the whole line of 'item2' and 'item3'.

I tried to use the CListCtrl class method SetTextColor()
and it worked so so. If I minimize the dialog and then
restore it again, the list is refreshed and it displays
all the items with the original text color.

What should I do to fix this problem or if you have
another solution to do this, please help me with it.

Thanks,
Geo
Nov 16 '05 #1
2 2164
Hi,
I'm using a List Control (report view) in a dialog. This
list displays 4 text items, each consisting of 3 columns.
Let's consider the following example:

Title of column1 Title c2 Title c3 Title c4
Item1 info12 info13 info14
Item2 info22 info23 info24
Item3 info32 info33 info34
Item4 info42 info43 info44

I want to change the text color of an item if a cetain
condition is true. In the example above, say I want to
change the color of the whole line of 'item2' and 'item3'.

I tried to use the CListCtrl class method SetTextColor()
and it worked so so. If I minimize the dialog and then
restore it again, the list is refreshed and it displays
all the items with the original text color.

What should I do to fix this problem or if you have
another solution to do this, please help me with it.


If you are using ListView Windows Common Control, see NM_CUSTOMDRAW
notification message.

...
Regards,
Vadim.
Nov 16 '05 #2
Hi,
I am using CListCtrl and everything is working fine with
it except this text color thing. I checked the CListView
class and I'm affraid if I use it I'll have to draw
everything in the list by myself and this is hard to do.
CListCtrl is MFC wrapper for Windows ListView Common Control, I mentioned in
previous post. So everything is OK, you should not replace it with
CListView.
When I say everything, I mean I have to take care of the
text font, text color, the selecttion, drawing of
rectangles, ...


Have a look at NM_CUSTOMDRAW (list-view) notification one more time. It's
sent to the parent window of list view control. It's quite flexible
mechanism and doesn't require in entire control redrawing, it's possible to
override only for example text color. Below is code sample changing text and
background colors, it doesn't use MFC, so I'd recommend you ask this
question on MFC group and search on www.codeproject.com and www.codeguru.com
, IIRC there were a lot of samples demonstrating custom-draw in list-view
control.

<code>
LRESULT CSomeParentWnd::OnNotify_CustomDraw(int idCtrl, LPNMHDR pnmh, BOOL&
bHandled)
{
if( pnmh->hwndFrom==m_wndHistory )
{
NMLVCUSTOMDRAW* p = reinterpret_cast<NMLVCUSTOMDRAW*>(pnmh);
//ATLTRACE(_T("Stage: %d 0x%08x\n"), p->nmcd.dwDrawStage,
p->nmcd.dwDrawStage);
switch(p->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
return CDRF_NOTIFYITEMDRAW;

case CDDS_ITEMPREPAINT:
return CDRF_NOTIFYSUBITEMDRAW;

case (CDDS_ITEMPREPAINT | CDDS_SUBITEM):
{
int nIndex = static_cast<int>(p->nmcd.lItemlParam);
if( nIndex>=0 && nIndex<m_aHistory.GetSize() )
{
p->clrText = m_aHistory[nIndex]->clrText;
if( p->iSubItem==eCol_Bpm )
p->clrTextBk = m_aHistory[nIndex]->clrTextBk;
else
p->clrTextBk = m_aHistory[nIndex]->clrTextBkDef;
}
}
return CDRF_DODEFAULT;
}
}
return CDRF_DODEFAULT;
}

</code>
...
Regards,
Vadim.
Nov 16 '05 #3

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

Similar topics

6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
5
by: John Flynn | last post by:
hi all i'm going to be quick i have an assignment due which i have no idea how to do. i work full time so i dont have the time to learn it and its due date has crept up on me .. As follows:...
5
by: TrvlOrm | last post by:
HI There, I have been struggling with JavaScript code for days now, and this is my last resort! Please help... I am trying to create a JavaScript slide show with links for Next Slide,...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
8
by: skumar434 | last post by:
i need to store the data from a data base in to structure .............the problem is like this ....suppose there is a data base which stores the sequence no and item type etc ...but i need only...
8
by: CM | last post by:
Hi, Could anyone please help me? I am completing my Master's Degree and need to reproduce a Webpage in Word. Aspects of the page are lost and some of the text goes. I would really appreciate it....
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
21
by: asif929 | last post by:
I need immediate help in writing a function program. I have to write a program in functions and use array to store them. I am not familiar with functions and i tried to create it but i fails to...
5
by: Justin | last post by:
Here's my XML: <?xml version="1.0" ?> <AppMode Type="Network"> <CurrentFolder Path="c:\tabs"> <Tabs> <FilePath>tabs\Justin.tab</FilePath> <FilePath>tabs\Julie.tab</FilePath> *****There could...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.