Skip to main content

Using the BuildPageSetupMenu method with the standard Delphi menu system

Standard Delphi menu system is used in the Print Preview dialog when Standard is assigned to the PreviewDialogStyle property of the currently active engine controller or dxPSEngine global object. This topic demonstrates how to populate a TPopupMenu with print styles available via the Print Preview dialog’s File | Print Styles sub menu.

Page Setup Menu

Drop a TdxPrintStyleManager component on a form.

Assign the following code to the OnChangeCurrentStyle event handler:

var
  PopupMenu: TPopupMenu;
//...
procedure TMyForm.dxPrintStyleManager1ChangeCurrentStyle(Sender: TObject)
var
  I: Integer;
begin
  for I := 0; to PopupMenu.Items.Count - 1 do
    PopupMenu.Items[I].Checked := TBasedxPrintStyle(PopupMenu.Items[I].Tag) = dxPrintStyleManager1.CurrentStyle;
end;

Assign the following code to the OnStyleListChanged event handler:

procedure TMyForm.dxPrintStyleManager1StyleListChanged(Sender: TObject)
begin
  PopupMenu.Items.Clear;
  dxComponentPrinter1.CurrentLink.BuildPageSetupMenu(PopupMenu.Items, nil, True);
end;