Board index » cppbuilder » How to "actually draw the entire item yourself manually."?

How to "actually draw the entire item yourself manually."?


2004-09-10 10:55:21 AM
cppbuilder80
Quote
As far as I know, the only way to change the highlight color is to set
DefaultDraw to false and then actually draw the entire item yourself
manually.
How to "actually draw the entire item yourself manually."?
I didn't find those codes in <BC>/Source/vcl/comctrls.pas.
Would you like to show me the codes?
 
 

Re:How to "actually draw the entire item yourself manually."?

"Jackie" < XXXX@XXXXX.COM >wrote in message
Quote
How to "actually draw the entire item yourself manually."?
Simply draw everything yourself on the Canvas. Use the Canvas' FillRect()
method to draw the background using whatever Brush Color, you want, and use
the TextRect() method to draw the item's text on top of the background. The
State parameter of the event handler tells you whether the item being drawn
should be drawn highlighted, focused, etc.
Quote
I didn't find those codes in <BC>/Source/vcl/comctrls.pas.
That is because ComCtrls is not drawing the items to begin with. The OS
itself is.
Gambit
 

Re:How to "actually draw the entire item yourself manually."?

Thank you very much, though I don't think I understand about the "The OS
itself is".
These codes can change highlight color to yellow.
But not subitems, how can I know the subitem's Caption and their Position?
void __fastcall TFormMain::_listCustomDrawItem(TCustomListView *Sender,
TListItem *Item, TCustomDrawState State, bool &DefaultDraw)
{
if( State.Contains(cdsSelected) )
{
TRect rect_head, rect = Item->DisplayRect(drLabel);
GetWindowRect(FindWindowEx(_list->Handle, 0, "SysHeader32", NULL),
&rect_head);
rect.Right = rect_head.Right;
_list->Canvas->Brush->Color = clYellow;
_list->Canvas->FillRect(rect);
_list->Canvas->TextOut(rect.Left + 2, rect.Top, Item->Caption);
DefaultDraw = false;
}
}
 

{smallsort}