TdxBarListItem Example
The following code demonstrates organization of MDI child lists with the help of the TdxBarListItem object. If the ShowCheck property of a given class is equal to True, then at the current item (in our case it is the current MDI child form) a “check” is displayed. While selecting any window from the list, it becomes active - While destroying - it removes the corresponding string. This example assumes that the window caption contains the file name. With the change of this name, the caption and the corresponding string in the MDI child list also changes.
MainForm: TMainForm;
dxBarListWindows: TdxBarListItem;
dxBarListWindows.ShowCheck := True;
// ...
//In MDI child (TChildForm.FormStyle = fsMDIChild):
procedure TChildForm.FormCreate(Sender: TObject);
begin
Inc(MainForm.CreatedMDICount);
Caption := 'Document' + IntToStr(MainForm.CreatedMDICount);
MainForm.dxBarListWindows.Items.AddObject(Caption, Self);
end;
procedure TChildForm.FormDestroy(Sender: TObject);
begin
with MainForm.dxBarListWindows.Items do
Delete(IndexOfObject(Self));
end;
procedure TChildForm.SetFileName(Value: string);
var
I: Integer;
begin
Caption := Value;
with MainForm.dxBarListWindows do
begin
I := Items.IndexOfObject(Self);
if (0 <= I) and (I < Items.Count) then Items[I] := Value;
end;
end;
// in MDI frame (TMainForm.FormStyle = fsMDIForm):
procedure TMainForm.dxBarListWindowsGetData(Sender: TObject);
begin
with dxBarListWindows do
ItemIndex := Items.IndexOfObject(ActiveMDIChild);
end;
procedure TMainForm.dxBarListWindowsClick(Sender: TObject);
begin
with dxBarListWindows do
if ItemIndex > -1 then
TCustomForm(Items.Objects[ItemIndex]).Show;
end;