3

I found the VB function ShowPhotoPrintingWizard:

CommonDialog.ShowPhotoPrintingWizard( _
  ByVal Files As VARIANT _
) As HRESULT

How do I call that or get equivalent functionality in Delphi? I'm using Delphi 2010.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
Bill
  • 2,993
  • 5
  • 37
  • 71

1 Answers1

6

I think it might be this way for a single file:

uses
  ComObj;

procedure TForm1.Button1Click(Sender: TObject);
var
  CommDlg: OleVariant;
begin
  CommDlg := CreateOleObject('WIA.CommonDialog');
  CommDlg.ShowPhotoPrintingWizard('d:\Image.jpg');
end;

Or the similar for multiple files:

procedure TForm1.Button1Click(Sender: TObject);
var
  Files: OleVariant;
  CommDlg: OleVariant;
begin
  CommDlg := CreateOleObject('WIA.CommonDialog');
  Files := CreateOleObject('WIA.Vector');
  Files.Add('d:\Image 1.jpg');
  Files.Add('d:\Image 2.jpg');
  CommDlg.ShowPhotoPrintingWizard(Files);
end;
TLama
  • 75,147
  • 17
  • 214
  • 392
  • @Andreas, thanks! I originally chose the first one matching `Wizard` in the `CommonDialog` method list. Shame on me! :-) – TLama Mar 26 '13 at 18:42
  • Can the printing wizard be used if you have the images as TBitmaps? Maybe another question? – Bill Mar 26 '13 at 19:14
  • No, the `ShowPhotoPrintingWizard` method accepts only files, not any kind of stream, so you'll have to save the `TBitmap` images to files. And yes, that should have been a separate question ;-) – TLama Mar 26 '13 at 19:17