We help IT Professionals succeed at work.

Decoding clipboard for jpeg and multiple selections

Mutley2003
Mutley2003 asked
on
687 Views
Last Modified: 2011-10-03
I need a bit of help here in sorting out the clipboard with multiple, including non standard images.

What I want to do is allow the user to select multiple "images" from Explorer, copy and then paste into my app. More specificallly, paste the info into my app so that I can then decide what to do with it.

To start with, suppose I have a single jpeg file selected and copied to the clipboard.  The code below
says that the clipboard contains  9 objects

DataObject
Shell IDList Array
CF_HDROP (Win 95)
DataObjectAttributes
Preferred DropEffect
Shell Object Offsets
FileName
FileNameW
Ole Private Data

- so, how can I interpret this lot as meaning that the clipboard contains a single jpeg filename, and how do I then go get the filename?


If I select and copy multiple objects, I get something quite similar (only 8 entries this time)
DataObject
Shell IDList Array
CF_HDROP (Win 95)
DataObjectAttributes
Preferred DropEffect
FileName
FileNameW
Ole Private Data

Where do I go from here?





=============================================================

procedure TForm1.BtnShowFormatsClick(Sender: TObject);
{
  http://www.efg2.com/Lab/Library/UseNet/2001/1124.txt
}
Var
  buf: Array [0..60] of Char;
  n  : Integer;
  fmt: Word;
  name: String[30];
begin
  dsmemo1.Clear;
  for n := 0 to Clipboard.FormatCount-1 do begin
    fmt := Clipboard.Formats[n];
    If GetclipboardFormatName( fmt, buf, Pred(Sizeof(buf))) <> 0 Then
      memo1.Lines.Add( StrPas( buf ))
    Else Begin
      Case fmt of
          1: name := 'CF_TEXT';
          2: name := 'CF_BITMAP';
          3: name := 'CF_METAFILEPICT';
          4: name := 'CF_SYLK';
          5: name := 'CF_DIF';
          6: name := 'CF_TIFF';
          7: name := 'CF_OEMTEXT';
          8: name := 'CF_DIB';
          9: name := 'CF_PALETTE';
         10: name := 'CF_PENDATA';
         11: name := 'CF_RIFF';
         12: name := 'CF_WAVE';
         13: name := 'CF_UNICODETEXT';
         14: name := 'CF_ENHMETAFILE';
         15: name := 'CF_HDROP (Win 95)';
         16: name := 'CF_LOCALE (Win 95)';
         17: name := 'CF_MAX (Win 95)';
      $0080: name := 'CF_OWNERDISPLAY';
      $0081: name := 'CF_DSPTEXT';
      $0082: name := 'CF_DSPBITMAP';
      $0083: name := 'CF_DSPMETAFILEPICT';
      $008E: name := 'CF_DSPENHMETAFILE';
      $0200..$02FF: name := 'private format';
      $0300..$03FF: name := 'GDI object';
     Else
       name := 'unknown format';
     End;
     memo1.Lines.Add( name );
   end;
  end;
end;
Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
Oops, small mistake - delete  "Form1.memo1.Clear;" line inside GetClipboardFiles function.

Author

Commented:
worked like a dream, thank you

Commented:
You are welcome ;)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.