Link to home
Start Free TrialLog in
Avatar of yarek
yarekFlag for France

asked on

delphi copy picture to clipboard

I need to do the following:

I have a JPEG/GIF picture on my disk: c:\image1.jpg
I need to copy this to the CLIPBoard
then when I open Outlook express, and I press CTRL+V (pasted command), I get this picture in the bdoy.

I treid several solutions but no one seem to work...
Thanks
Avatar of 2266180
2266180
Flag of United States of America image

use the following code:

uses jpeg, clipbrd;

procedure TForm1.FormCreate(Sender: TObject);
var j:TJPEGImage;
begin
  j:=TJPEGImage.Create;
  j.LoadFromFile('c:\test.jpg');
  clipboard.Assign(j);
  j.free;
end;
Avatar of yarek

ASKER

This works fine for WORD but NOT in OUTLOOK EXPRESS ! ! !
Please do try it !
I don't have outlook express. sorry. I tested it with ms paint :)
maybe outlook express doesn't know jpg? try this for bitmap:

uses jpeg, clipbrd, ExtCtrls;

procedure TForm1.FormCreate(Sender: TObject);
var j:TJPEGImage; i:TImage;
begin
  j:=TJPEGImage.Create;
  j.LoadFromFile('c:\test.jpg');
  i:=TImage.create(nil);
  i.Picture.Bitmap.Assign(j);
  clipboard.Assign(i.Picture.Bitmap);
  i.Free;
  j.free;
end;
Avatar of yarek

ASKER

DOES NOT WORK in OUTLOOK EXPRESS !
DOes not work in DreamWeaver !
Does not work in WYSIWYG HTML editor like HTMLArea !
but works fine in paint and other "normal" applications like wordpad, borland delphi image editor, microsoft html help image editor, microsoft word, gimp, openoffice writer and teh list can go on and on and on.
I have no application on my system that should support pasting images from clipboard that I tested and did not work. none.

are you sure those applications have such functionality? not copy/paste images from their UI but pasting an image that was saved to clipboard from .. ms paint for example.

Hi,

Testing in OE6 doesn't work.

You can't paste a picture int his way.

To add a picture in a new html message in OE Express, you need to use the menu Insert -> Picture and in the dialog box supply the picture source your want to insert in your message and eventually the alternate text and position.

This is a html editor like others: if you request the source of a blank message you get

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.5730.11" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BODY></HTML>


I you insert a picture, you get when you ask for the source (Menu Displayig -> Modify the source):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.5730.11" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2><IMG alt="" hspace=0 src="C:\test.jpg"
align=baseline border=0></FONT></DIV></BODY></HTML>


You got also a Format -> Background -> Image

Insert a background picture and the source gives you:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.5730.11" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff background=C:\test.jpg>
<DIV>&nbsp;</DIV></BODY></HTML>


So, I believe the best way is using Sendkey to invoke each of those menu items to insert the picture from a file (and not from clipboard).

Hope this help.





See also this link

http://www.microsoft.com/technet/archive/itsolutions/intranet/manage/collab.mspx?mfr=true

where it's stated:

If you use Communicator's message composer, there are three ways to include an image.
•      Drag it from a browser window and drop it onto Composer's canvas
•      Use the image tool on the toolbar's Insert Object dropdown, then specify or navigate to the image file
•      Copy image data to the clipboard, and paste it into Composer (results vary depending on the format of the pasted bitmap).

If you use the Outlook Express composer, there is only one method: use the toolbar's Insert Picture function, then specify or navigate to the image file.




Avatar of yarek

ASKER

WHAT TOU SAY  IS FALSE

- Just copy a picture from Internet Explorer (CTRL+C)
- AND PASTE IT to Outlook express BODY (CTRL+V)

THAT IS WHAT I TRY TO ACHIEVE

best regards

no need to shout.

internet explorer is not an image editing program. it will copy on the clipboard a special image object.

try this instead: open IE, copy an image (ctrl+c) then open patin and paste it. (ctrl+v) see what happens.

if you want to copy such objects, you will need to eitehr use some existing API for it or find out the layout of the object and construct it from code. I would suggest searching for teh first possibility. but keep in mind that you will not be able to interact between normal image editing applications and html editing applications via clipboard. the objects just don't match.
correction "patin"=paint. fingers miss-crossed.

Hi,

Why are you shouting ?

Your initial question is:

"
I need to do the following:
I have a JPEG/GIF picture on my disk: c:\image1.jpg
I need to copy this to the CLIPBoard
then when I open Outlook express, and I press CTRL+V (pasted command), I get this picture in the bdoy.
I treid several solutions but no one seem to work..."

We (as well Ciuly as myself) were trying to answer that question and not a question on how to copy a picture from IE to OE.

Have you taken the time to read what MS writes in the doc (link above): "If you use the Outlook Express composer, there is only one method: use the toolbar's Insert Picture function, then specify or navigate to the image file."

In this sense,the use of Sendkey seems imo the more appropriate.

Display the source code of your message in OE (one of the 3 tabs in the editor) and paste the code above.
It will display the picture in the display window (tab "Display" or sth like this, I've got a French version).


Little correction:

the tab displaing the picture is named "Modifiy" (the frst tab) and not "Display" (the last one).
Avatar of yarek

ASKER

LET's STAY COOL...

I have already found 1 way to do it with an
CopyHTMLToClipBoard function

I believe there is a better way to do it as simualting an  InternetExplorer  CTRL+C
Best regards




Hi,

We are cool, don't worry ... ;)

Your function CopyHTMLToClipBoard will probably copy the html.code to the clipboard, not the picture but a link to this picture (and gives you a html code similar to this above).

To send a cltr+c  see on http://www.efg2.com/Lab/Library/Delphi/Miscellany/  (search in the page for SndKey32.pas).

Avatar of yarek

ASKER

Bernani,
thanks for your help. I know what CopyHTMLToClipBoard does and how it works.
It works just great cause the picture is indeed inserted and sent correctly.

NOW I AM STILL LOOKING FOR A LESS COMPLIACTED SOLUTION TO ACHIEVE THIS.

Thanks
You can use clipspy (http://www.geocities.com/SiliconValley/2060/clipspy.html) to see what IE puts to clipboard, so that OE can paste the picture.

I copied the Experts-Exchange logo at the top of this page.
IE put the following html data in the clipboard.
That's what you should do if you want to reproduce its behaviour. Otherwise, you'll have to load IE and send a ctrl+c.

I believe the headers and the
><!--StartFragment--><IMG height=75 src="/b.gif" width=300><!--EndFragment-->
part are enough, you don't need the rest of the html.

Version:1.0
StartHTML:000000251
EndHTML:000001029
StartFragment:000000921
EndFragment:000000959
StartSelection:000000921
EndSelection:000000959
SourceURL:https://www.experts-exchange.com/questions/22091690/delphi-copy-picture-to-clipboard.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">

<HTML><HEAD><TITLE>Delphi Programming: delphi copy picture to clipboard</TITLE><LINK
href="/images/ee.ico" rel="shortcut icon"><LINK
href="/scripts/ee_0cb72ce87a4a8a44ffd3908a6dda2de9.css" type=text/css
rel=stylesheet><LINK
href="/scripts/eeExpert_0b63c6a6a19d1b257183f53ccb4a7f20.css" type=text/css
rel=stylesheet>
<SCRIPT src="/scripts/eeSubs_88fcb4c868a5c02661171720cf388b79.js"
type=text/javascript></SCRIPT>
</HEAD>

<BODY>

<TABLE class=fullWidth>

<TBODY>

<TR>

<TD class=logoLeft rowSpan=2><!--StartFragment--><IMG height=75 src="/b.gif" width=300><!--EndFragment--></TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>
An other alternative to IE loading is:
1) embed a TWebbrowser (it may be hidden) in your app
2) tell it to navigate to c:\image.gif (or build an html page that has a <img src="c:\image.gif"> inside it
3) copy the image to clipboard using the webbrowser interfaces.
Avatar of yarek

ASKER

This last solution seems nice:

but how can I copy the image to clipboard using the webbrowser interfaces ?
ASKER CERTIFIED SOLUTION
Avatar of alkisg
alkisg
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial