type
PNewListBox = ^TNewListBox;
TNewListBox = object(TListBox)
destructor Done; virtual;
end;
...
destructor TNewListBox.Done;
begin
if List <> nil then begin
Dispose(List, Done);
end;
TListBox.Done;
end;
constructor TMyDialog.Init;
var
Rect: TRect;
ScrollBar: PScrollBar;
i: Sw_Integer;
const
Tage: array [0..6] of shortstring = (
'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag');
begin
Rect.Assign(10, 5, 67, 17);
inherited Init(Rect, 'ListBox Demo');
// StringCollection
StringCollection := new(PStringCollection, Init(5, 5));
for i := 0 to Length(Tage) - 1 do begin
StringCollection^.Insert(NewStr(Tage[i]));
end;
// ScrollBar für ListBox
Rect.Assign(31, 2, 32, 7);
ScrollBar := new(PScrollBar, Init(Rect));
Insert(ScrollBar);
// ListBox
Rect.Assign(5, 2, 31, 7);
ListBox := new(PNewListBox, Init(Rect, 1, ScrollBar));
ListBox^.NewList(StringCollection);
Insert(ListBox);
// Cancel-Button
Rect.Assign(19, 9, 32, 10);
Insert(new(PButton, Init(Rect, '~T~ag', cmTag, bfNormal)));
// Ok-Button
Rect.Assign(7, 9, 17, 10);
Insert(new(PButton, Init(Rect, '~O~K', cmOK, bfDefault)));
end;