3

Hello I use Delphi 2010 + Windows XP, you can call the Photo Printing Wizard in Windows XP At Delphi.

How do I show the Windows photo-printing wizard?

above this tip only works on windows 7

Thank you.

Community
  • 1
  • 1

1 Answers1

6

MSDN includes sample code for that:

static const CLSID CLSID_PrintPhotosDropTarget = 
  {0x60fd46de, 0xf830, 0x4894, {0xa6, 0x28, 0x6f, 0xa8, 0x1b, 0xc0, 0x19, 0x0d}};

// A data object that contains the list of photos to print.
IDataObject* pDataObject;

// Create the Photo Printing Wizard drop target.
CComPtr<IDropTarget> spDropTarget;

hr = CoCreateInstance(CLSID_PrintPhotosDropTarget,
                      NULL,
                      CLSCTX_INPROC_SERVER,
                      IID_PPV_ARGS(&spDropTarget));

// Drop the data object onto the drop target.
POINTL pt = {0};
DWORD dwEffect = DROPEFFECT_LINK | DROPEFFECT_MOVE | DROPEFFECT_COPY;

spDropTarget->DragEnter(pDataObject, MK_LBUTTON, pt, &dwEffect);

spDropTarget->Drop(pDataObject, MK_LBUTTON, pt, &dwEffect);

Delphi code would be something like this:

uses
  ActiveX, ComObj;

const
  CLSID_PrintPhotosDropTarget: TGUID = '{60FD46DE-F830-4894-A628-6FA81BC0190D}';

procedure InvokePhotoPrintingWizard;
var
  Effect: LongInt;
  Position: TPoint;
  DataObject: IDataObject;
  DropTarget: IDropTarget;
begin
  // create the Photo Printing Wizard drop target
  OleCheck(CoCreateInstance(CLSID_PrintPhotosDropTarget, nil,
    CLSCTX_INPROC_SERVER, IDropTarget, DropTarget));
  // drop the data object onto the drop target
  Position.X := 0;
  Position.Y := 0;
  Effect := DROPEFFECT_LINK or DROPEFFECT_MOVE or DROPEFFECT_COPY;
  OleCheck(DropTarget.DragEnter(DataObject, MK_LBUTTON, Position, Effect));
  OleCheck(DropTarget.Drop(DataObject, MK_LBUTTON, Position, Effect));
end;
TLama
  • 75,147
  • 17
  • 214
  • 392
Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • Thanks Friend, as I pass the string with the file path does not get it right can help me pass the full path eg C: \ photo.jpg it is possible to create a function so ShowPrinteWizard procedure (aFilePath: string); Again thanks for your help. – Wesley Bobato Mar 26 '13 at 22:43
  • 1
    You'd have to stuff the file name into an IDataObject. That's beyond the scope of this question. See [*How can I create a IDataObject instance with Delphi?*](http://stackoverflow.com/q/976727/33732) for some advice on creating something that implements `IDataObject`. You can either implement the interface yourself, or follow [the link](http://www.swissdelphicenter.ch/de/showcode.php?id=2335) to some example code that builds a list of files and then calls `GetUIObjectOf` to get a data object representing all of them. – Rob Kennedy Mar 26 '13 at 22:53
  • Thanks Friend I'll try but I know I can not because it is too advanced for me, A Big Hug. – Wesley Bobato Mar 26 '13 at 23:03
  • Hello TLama Unfortunately Runs on Windows XP, how could I pass the file path in InvokePhotoPrintingWizard procedure; for example the path below the file. C: \ picture.jpeg in Function – Wesley Bobato Mar 27 '13 at 14:58
  • 1
    Wesley, all you have to do is fill `DataObject`, and I've given you links demonstrating that already. I know you said it's hard, but such is life. This particular part of the Windows API isn't trivial. Sit down, read it carefully, consult with MSDN when you encounter a function you haven't seen before, and you'll learn it. If you're still lost, then post a new question here asking about the specific part you don't understand. – Rob Kennedy Mar 27 '13 at 15:19