DHTMLEdit - Registered Users - Helpdesk
Copy Image to Clipboard
Thread Starter: Possum Started: 6/24/2008 8:07 PM UTC
Replies: 1
Copy Image to Clipboard
Hi

Is there a way to copy an image in HTMLEdit to the clipboard


Cheers Peter..
Re: Copy Image to Clipboard
Hi Peter:

procedure TForm1.ToolButton1Click(Sender: TObject);
var
 D: IDispatch;
 Element: IHTMLElement;
 B: TBitmap;
 ImgElement: IHTMLImgElement;
begin
 if ProfDHTMLEdit21.IsImageSelected then
   if ProfDHTMLEdit21.GetDOM(D) then
   begin
     Element := ((D as IHTMLDocument2).selection.createRange as IHTMLControlRange).commonParentElement;
     B := TBitmap.Create;
     try
       ImgElement := Element as IHTMLImgElement;
       B.Width := ImgElement.width;
       B.Height := ImgElement.height;
       (Element as IHTMLElementRender).DrawToDC(B.Canvas.Handle);
       Clipboard.Assign(B)
     finally
       B.Free
     end
   end
end;


-Nicholas