TsCheckListBox and DrawItem-method

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #47378
    ralfiii
    Participant

    I have changed the code for the TsCheckListBox and attached a pic of my current (left) and the normal (right) focus rect and my current focus rect, just to make it easier to understand what my problem is.

    Here's the code:

    Code:
    procedure TForm1.sCheckListBox1DrawItem(Control: TWinControl; Index: Integer;
    Rect: TRect; State: TOwnerDrawState);
    var IsSelected : boolean;
    const ColorFieldWidth = 10;
    const ColArr : array[0..3] of TColor = (clBlack, clRed, clBlue, clYellow);
    begin
    IsSelected:=odSelected in State;

    with (Control as TsCheckListBox) do
    begin
    // Clear Cell
    if IsSelected then
    begin
    Canvas.Brush.Color:=$00AED7FF;
    Canvas.FillRect(Rect);
    end;

    // Draw Colorfield
    Canvas.Brush.Color:=ColArr[Index mod 4];
    with Rect do
    Canvas.FillRect(Classes.Rect(Left+2,Top+2,Left+2+ColorFieldWidth,Bottom-3));

    // Output Text
    Canvas.Brush.Style:=bsClear;
    Canvas.Font.Color:=clBlack;
    with Rect do
    Canvas.TextOut(Left+ColorFieldWidth+7, Top+1, Items[Index]);
    end;
    end;

    #47410
    Support
    Keymaster

    Thanks for message, this topic was moved to 'Tips and tricks'.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.