[delphi] view plain copy
- uses
- ActiveX,ComObj;
- procedure TfrmMain.FormCreate(Sender: TObject);
- begin
- OleInitialize(nil);
- end;
- procedure TfrmMain.DomImg2Image(wb:TWebBrowser);
- var
- i:Integer;
- rang:IHTMLControlRange;
- s:string;
- begin
- try
- //pic是图片的节点(层)名称,你打开源代码看一下,替换成你的就行了
- s := (IHTMLDocument2(wb.Document).images.item(‘pic‘,EmptyParam) as IHTMLElement).getAttribute(‘src‘,0);
- //showmessage(s);
- rang:=((IHTMLDocument2(wb.Document).body as HTMLBody).createControlRange)as
- IHTMLControlRange;
- rang.add(IHTMLDocument2(wb.Document).images.item(‘pic‘,EmptyParam)as
- IHTMLControlElement);
- rang.execCommand(‘Copy‘,False,0);
- image1.Picture.Assign(ClipBoard);
- except
- end;
- end;
- procedure TfrmMain.FormDestroy(Sender: TObject);
- begin
- OleUninitialize;
- end;
http://blog.csdn.net/yanjiaye520/article/details/7955671
时间: 2024-11-06 21:21:33