2013-03-26 77 views

回答

5

MSDN包括对示例代码:

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代码会是这样的:

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; 
+0

感谢朋友,因为我通过与文件路径字符串不得到它的权利能帮助我通过完整路径,例如: C:\ photo.jpg 可以创建一个函数,如 ShowPrinteWizard过程(aFilePath:string); 再次感谢您的帮助。 – 2013-03-26 22:43:47

+1

您必须将文件名填入IDataObject。这超出了这个问题的范围。请参阅[*如何使用Delphi创建一个IDataObject实例?](http://stackoverflow.com/q/976727/33732)以获取关于创建实现'IDataObject'的某些建议。您可以自己实现接口,或者按照[链接](http://www.swissdelphicenter.ch/de/showcode.php?id=2335)创建一个文件列表的示例代码,然后调用'GetUIObjectOf '得到一个代表所有这些数据的数据对象。 – 2013-03-26 22:53:11

+0

谢谢朋友我会尝试,但我知道我不能,因为它对我来说太高级了, A Big Hug。 – 2013-03-26 23:03:43