|
TListItem 의 메서드
Windows::TRect __fastcall DisplayRect(TDisplayCode Code);
를 이용하십시요.
ListView 의 오우너드로우에 대한 예제가 헬프엔 없던데
TreeView 에는 조금 나와 있습니다.비슷한거 같던데 그걸 참고해 보십시요
아래는 트리뷰example
void __fastcall TCustomDrawForm::TVCustomDrawItem(TCustomTreeView *Sender, TTreeNode *Node, TCustomDrawState State, bool &DefaultDraw)
{
TRect NodeRect;
//If DefaultDraw it is true, any of the node's font properties can be
//changed. Note also that when DefaultDraw is true, Windows draws the
//buttons and ignores our font background colors, using instead the
//TreeView's Color property.
if (State.Contains(cdsSelected))
{
TV->Canvas->Font->Assign(SelectedFontDialog->Font);
TV->Canvas->Brush->Color = SelBkgColorDialog->Color;
}
DefaultDraw = FDefaultDrawItem;
//DefaultDraw = False means you have to handle all the item drawing yourself,
//including the buttons, lines, images, and text.
if (!DefaultDraw)
{
//draw the selection rect.
if (State.Contains(cdsSelected))
{
NodeRect = Node->DisplayRect(true);
TV->Canvas->FillRect(NodeRect);
}
NodeRect = Node->DisplayRect(false);
if (None1->Checked)
{
//no bitmap, so paint in the background color.
TV->Canvas->Brush->Color = BkgColorDialog->Color;
TV->Canvas->Brush->Style = FBrushStyle;
TV->Canvas->FillRect(NodeRect)
}
else //don't paint over the background bitmap.
TV->Canvas->Brush->Style = bsClear;
NodeRect->Left = NodeRect->Left + (Node->Level * TV->Indent);
//NodeRect.Left now represents the left-most portion of the expand button
TV->Canvas->DrawButton(NodeRect, Node);
NodeRect->Left = NodeRect->Left + TV->Indent + FButtonSize;
//NodeRect.Left is now the leftmost portion of the image.
TV->Canvas->DrawImage(NodeRect, Node->ImageIndex);
NodeRect->Left = NodeRect->Left + ImageList->Width;
//Now we are finally in a position to draw the text.
TV->Canvas->TextOut(NodeRect->Left, NodeRect->Top, Node->Text);
}
}
김병은 님이 쓰신 글 :
: 방태윤 님이 쓰신 글 :
: : OwnerDraw = true 에 상관없이
: : CustomDrawItem 이벤트는 발생됩니다.
: :
: CustomDrawItem 은 Rect가 없습니다.
: 전 Rect가 필요합니다.
:
: 왜 OwnerDraw = true를 해도 OnDrawItem 이벤트가 발생하지 않는 걸까요.
:
:
:
|