<div style="height:200px;background-image:url(1.jpg);" id="div1" /> 我要保存div1的图片,怎么保存呢?我用下面的方法不能保存
procedure TForm1.Button7Click(Sender: TObject);
var
d2,D:IHTMLDocument2;
d1:IHTMLDocument;
e:IHTMLElement;
e2:IHTMLElement2;
cp:IHTMLControlRange;
img,img1:IHTMLImgElement;
ce:IHTMLControlElement;
myitem:Olevariant;
i:integer;
rang:IHTMLControlRange;
doc: IHTMLDocument2;
mDiv: IHTMLElement;
begin
doc := WebBrowser1.Document as IHTMLDocument2;mDiv := doc.all.item('div3',0) as IHTMLElement;D:= webbrowser1.Document as IHTMLDocument2;
e:=d.body as IHTMLElement;
e2:=e as IHTMLElement2;
cp:=e2.createControlRange as IHTMLControlRange;
d2:= webbrowser1.Document as IHTMLDocument2;
myitem := WebBrowser1.Document;
ce:=mDiv as IHTMLControlElement;cp.add(ce);
cp.execCommand('Copy',false,0);
try
Image1.Picture.Assign(ClipBoard);
except
end;
end;
procedure TForm1.Button7Click(Sender: TObject);
var
d2,D:IHTMLDocument2;
d1:IHTMLDocument;
e:IHTMLElement;
e2:IHTMLElement2;
cp:IHTMLControlRange;
img,img1:IHTMLImgElement;
ce:IHTMLControlElement;
myitem:Olevariant;
i:integer;
rang:IHTMLControlRange;
doc: IHTMLDocument2;
mDiv: IHTMLElement;
begin
doc := WebBrowser1.Document as IHTMLDocument2;mDiv := doc.all.item('div3',0) as IHTMLElement;D:= webbrowser1.Document as IHTMLDocument2;
e:=d.body as IHTMLElement;
e2:=e as IHTMLElement2;
cp:=e2.createControlRange as IHTMLControlRange;
d2:= webbrowser1.Document as IHTMLDocument2;
myitem := WebBrowser1.Document;
ce:=mDiv as IHTMLControlElement;cp.add(ce);
cp.execCommand('Copy',false,0);
try
Image1.Picture.Assign(ClipBoard);
except
end;
end;
哦 不好意思 上面写错了 是div1的