How To…Launch the Label Wizard in Code

Question

“How do I launch the label wizard directly in code without having to go through the designer?”

Solution

Do this by manually creating a TppLabelTemplateWizard object and executing it.  Then it is up to you to manually create the report in code based on the user selections.

Download: LaunchLabelWizardInCode.zip

Sample Delphi code:

uses
  ppLabWiz;

procedure TForm1.btnLaunchWizardClick(Sender: TObject);
var
  lWizard: TppLabelTemplateWizard;
begin

  //See the attached example for sample implementations of the routines below.

  lWizard := TppLabelTemplateWizard.Create(Self);

  lWizard.OnCreateReport := CreateReportEvent;

  FReport := nil;

  if (lWizard.Execute) then
    begin
      {add code here to create the layout}
      AddComponentsToDetail(FReport);

      FReport.Print;
    end;

  lWizard.Free;

  FReport.Free;
end;