Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6368759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:42:59+00:00 2026-05-25T00:42:59+00:00

I draw list view items with OwnerDraw , but I have bugs: please resize

  • 0

I draw list view items with OwnerDraw, but I have bugs: please resize a column -> you will have a horizontal bar, scroll it -> items are drawn on a visible area 🙁

Please help me to edit a code below. Thanks for your attention and help!!!

Added:

I checked, Rect.Right and Rect.Left increase/decrease while scrolling. E.g. we scroll 50 px right, Rect.Right will be Rect.Right+50, Rect.Left will be -50 (0-50)

A normal view:

enter image description here

Bugs:

enter image description here
enter image description here

procedure TDownloadFrame.DownloadListDrawItem(Sender: TCustomListView;
  Item: TListItem; Rect: TRect; State: TOwnerDrawState);
var
  i: integer;
  x1, x2: integer;
  R: TRect;
  s: string;
const
  DT_ALIGN: array [TAlignment] of integer = (DT_LEFT, DT_RIGHT, DT_CENTER);
begin
  if odSelected in State then
  begin
    Sender.Canvas.Font.Color := clWhite;
    Sender.Canvas.Brush.Color := $00FF8000;
  end
  else
  begin
    Sender.Canvas.Font.Color := clBlack;
    Sender.Canvas.Brush.Color := clWhite;
  end;
  Sender.Canvas.Brush.Style := bsSolid;
  Sender.Canvas.FillRect(Rect);

  x1 := 0;
  x2 := 0;
  R := Rect;
  Sender.Canvas.Brush.Style := bsClear;
  MainForm.Icons_16x16.Draw(DownloadList.Canvas, 3, R.Top + (R.Bottom - R.Top - 16) div 2, 1, true);
  for i := 0 to DownloadList.Columns.Count - 1 do
  begin
    Inc(x2, ListView_GetColumnWidth(DownloadList.Handle,
      DownloadList.Columns[i].Index));
    R.Left := x1;
    R.Right := x2;
    if i = 0 then
    begin
      s := Item.Caption;
      R.Left := 16 + 6;
    end
    else
      s := Item.SubItems[i - 1];
    if i <> 3 then
    DrawText(Sender.Canvas.Handle, s, length(s), R, DT_SINGLELINE or
      DT_ALIGN[DownloadList.Columns[i].Alignment] or DT_VCENTER or
      DT_END_ELLIPSIS);
    x1 := x2;
  end;
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:43:01+00:00Added an answer on May 25, 2026 at 12:43 am

    Change:

    1)

      x1 := 0;
      x2 := 0;
    

    to

      x1 := Rect.Left;
      x2 := Rect.Left;
    

    2)

    MainForm.Icons_16x16.Draw(DownloadList.Canvas, 3, R.Top + (R.Bottom - R.Top - 16) div 2, 1, true);
    

    to

    MainForm.Icons_16x16.Draw(DownloadList.Canvas, R.Left+3, R.Top + (R.Bottom - R.Top - 16) div 2, ImgIndex, true);
    

    3)

    if i = 0 then
    begin
      s := Item.Caption;
      R.Left := 16 + 6;
    end
    

    to

     if i = 0 then
        begin
          s := Item.Caption;
          R.Left := R.Left + 16 + 6;
        end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list view and draw it with OwnerDraw . How to draw
Hallo everyone, i have a list of nodes ListNode and i want to draw
I have created one view, view code is, public class MyDraw extends View{ //List<Point>
I have create the list-activity.Now I want to add new view with with map
I have a listview with OwnerDraw = true and Details view mode. I want
Is it possible to have variable size (owner draw) items in the Win32 ListView,
As far as I know you can use Custom Draw in a list-view to
I want to draw some listview items disabled and would like to mimic the
To draw a circle on map I have a center GLatLng (A) and a
I'm trying to have a ListView that will display each row in a given

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.