Here's an example of converting a helper function to a global function...
HELPER METHOD:
procedure TListViewHelper.InitializeList(bFixLayout : Boolean = True);
const
Buffer_px = 4;
var
aListColumn: TListColumn;
begin
Clear;
if bFixLayout then
begin
ViewStyle := vsReport;
Columns.Clear;
end;
// Clear content
Clear;
// Setup the columns
if Columns.count < 2 then
begin
aListColumn := Columns.Add;
aListColumn.Caption := iemsg(IEMSG_NAME);
aListColumn.Width := Width div 3; // 1/3 width
aListColumn := Columns.Add;
aListColumn.Caption := iemsg(IEMSG_VALUE);
aListColumn.Width := MulDiv(Width, 3, 2) - GetSystemMetrics(SM_CYVSCROLL) - Buffer_px; // 2/3 width less Scrollbar width
end;
end;
GLOBAL METHOD:
procedure InitializeList(var aListView: TListView; bFixLayout: Boolean = True);
const
Buffer_px = 4;
var
aListColumn: TListColumn;
begin
with aListView do
begin
Clear;
if bFixLayout then
begin
ViewStyle := vsReport;
Columns.Clear;
end;
// Clear content
Clear;
// Setup the columns
if Columns.count < 2 then
begin
aListColumn := Columns.Add;
aListColumn.Caption := iemsg(IEMSG_NAME);
aListColumn.Width := Width div 3; // 1/3 width
aListColumn := Columns.Add;
aListColumn.Caption := iemsg(IEMSG_VALUE);
aListColumn.Width := MulDiv(Width, 3, 2) - GetSystemMetrics(SM_CYVSCROLL) - Buffer_px; // 2/3 width less Scrollbar width
end;
end;
end;
Nigel
Xequte Software
www.imageen.com