Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to add a color fill for selected column.
Drawing items I do in ListView1CustomDrawItem handler:
C++
Sender->Canvas->Brush->Color = RGB(200, 200, 255);

   if(Item->Selected)
   {
   Sender->Canvas->Brush->Color = (Sender->Focused() ? clBlue : clRed);
   }

Sender->Canvas->Lock();
Sender->Canvas->FillRect(Item->DisplayRect(drBounds));
Sender->Canvas->TextOut(Item->DisplayRect(drLabel).Left, Item->DisplayRect(drLabel).Top + 1, Item->Caption);
Sender->Canvas->Unlock();
DefaultDraw = false;

And if I understand correctly, drawing the selected column I should do in the ListView1CustomDraw handler:
C++
TRect rect;
rect = ARect;
rect.Right = Sender->Column[0]->Width;

Sender->Canvas->Brush->Color = RGB(245, 245, 245);


Sender->Canvas->Lock();
Sender->Canvas->FillRect(rect);
Sender->Canvas->Unlock();

And the result is:

http://i63.fastpic.ru/big/2014/1120/ba/e5b6d30eb9e05bbe3661aed295c28aba.jpg

It can also be seen on the video: http://youtu.be/XGXpWCUtGbU

As you can see, when I move (do not click) the cursor over the items, they are redrawn incorrectly. But the items must be drawn over the column colored rectangle. How can I fix this?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900