unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls,commctrl, StdCtrls, Math;
type
TmyListView =
class(TCustomListView)
private
protected
public
procedure CreateWnd;
override;
procedure Resize;
override;
published
Constructor Create(AOwner : TComponent);
Override;
property Align;
property AllocBy;
property Anchors;
property BiDiMode;
property BorderStyle;
property BorderWidth;
property Checkboxes;
property Color;
property ColumnClick
Default True;
property Constraints;
property Ctl3D;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property FlatScrollBars;
property FullDrag;
property GridLines;
property HideSelection;
property HotTrack;
property HotTrackStyles;
property IconOptions;
property MultiSelect;
property ReadOnly default False;
Property RowSelect;
property ParentBiDiMode;
property ParentColor
default False;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowColumnHeaders;
property ShowHint;
property TabOrder;
property TabStop
default True;
property ViewStyle;
property Visible;
property OnChange;
property OnChanging;
property OnClick;
property OnColumnClick;
property OnCustomDraw;
property OwnerDraw;
property OnCustomDrawItem;
property OnCustomDrawSubItem;
property OnDblClick;
property OnDeletion;
property OnDragOver;
property OnDragDrop;
property OnDrawItem;
property OnEdited;
property OnEditing;
property OnEndDock;
property OnEnter;
property OnExit;
property OnInsert;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnSelectItem;
property OnStartDock;
end;
type
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormCanResize(Sender: TObject;
var NewWidth,
NewHeight: Integer;
var Resize: Boolean);
private
{ Private declarations }
FmyLv: TmyListView;
FResizeWidthDelta: integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Constructor TmyListView.Create(AOwner: TComponent);
Begin
Inherited Create(AOwner);
Parent := TWinControl(AOwner);
DoubleBuffered := TRUE;
Name := '
myLv1';
Left := 20;
Top := 20;
Height := 30;
Width := 217;
Align := alNone;
BorderStyle := bsSingle;
BorderWidth := 0;
ViewStyle := vsIcon;
IconOptions.Arrangement := iaTop;
IconOptions.AutoArrange := TRUE;
IconOptions.WrapText := FALSE;
SortType:= stNone;
MultiSelect:= FALSE;
Anchors := [akLeft,akTop];
FlatScrollBars := TRUE;
TabStop := FALSE;
ReadOnly := TRUE;
HideSelection := FALSE;
ShowHint := TRUE;
ShowColumnHeaders := FALSE;
Items.Add.Caption := '
A';
Items.Add.Caption := '
B';
Items.Add.Caption := '
C';
Items.Add.Caption := '
D';
Items.Add.Caption := '
E';
Items.Add.Caption := '
F';
Items.Add.Caption := '
G';
Items.Add.Caption := '
H';
ViewStyle := vsSmallIcon;
end;
procedure TmyListView.CreateWnd;
begin
inherited CreateWnd;
FlatSB_SetScrollProp(
Handle, WSB_PROP_CXVSCROLL, 0, FALSE);
FlatSB_SetScrollProp(
Handle, WSB_PROP_CXHSCROLL, 0, FALSE);
FlatSB_SetScrollProp(
Handle, WSB_PROP_CYVSCROLL, 0, FALSE);
FlatSB_SetScrollProp(
Handle, WSB_PROP_CYHSCROLL, 0, FALSE);
FlatSB_SetScrollProp(
Handle, WSB_PROP_CXHTHUMB, 0, FALSE);
FlatSB_SetScrollProp(
Handle, WSB_PROP_CYVTHUMB, 0, TRUE);
end;
procedure TmyListView.Resize;
var i: integer;
maxW, maxH: integer;
r: TRect;
begin
if (csDesigning
in ComponentState)
then exit;
if Items.Count <= 0
then exit;
maxW:=0;
maxH:=0;
for i:= 0
to Items.Count-1
do
begin
r := Items[i].DisplayRect(drBounds);
maxW := Max(maxW, r.Right);
maxH := Max(maxH, r.Bottom);
end;
Height := maxH+ 10;
end;
//=======================================
procedure TForm1.FormCreate(Sender: TObject);
begin
FResizeWidthDelta := 0;
FmyLv := TmyListView.Create(Self);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FmyLv.Free;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
FmyLv.Width:= FmyLv.Width + FResizeWidthDelta;
end;
procedure TForm1.FormCanResize(Sender: TObject;
var NewWidth,
NewHeight: Integer;
var Resize: Boolean);
begin
if NewWidth <> Width
then
FResizeWidthDelta := (NewWidth - Width);
Resize := TRUE;
end;
initialization
finalization
end.