高手,这个问题我想了好久也没有答案,今天终于找到了,这个程序在d5+win98下可用
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleCtnrs, ActiveX, ComObj, ComCtrls;
type
TForm1 = class(TForm)
OleContainer1: TOleContainer;
Button1: TButton;
DateTimePicker1: TDateTimePicker;
Button2: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
Data: IDataObject;
SM: TStgMedium;
FormatEtc: TFormatEtc;
Bmp: TBitmap;
begin
OleContainer1.DoVerb(ovShow);
Data := OleContainer1.OleObjectInterface as IDataObject;
FormatEtc.cfFormat := CF_BITMAP;
FormatEtc.tymed := TYMED_GDI;
FormatEtc.ptd := nil;
FormatEtc.dwAspect := DVASPECT_CONTENT;
FormatEtc.lindex := -1;
Bmp := TBitmap.Create;
try
OleCheck(Data.GetData(FormatEtc, SM));
try
Bmp.LoadFromClipboardFormat(CF_BITMAP, SM.hBitmap, 0);
Bmp.SaveToFile('e:/Test.bmp');
finally
ReleaseStgMedium(SM);
end;
finally
Bmp.Free;
end;
end;
end.