ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Paste a file from clipboard into ImageEn

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Homer Posted - Dec 15 2021 : 15:38:24
When pasting a file from the clipboard, I don't know how to determine how to save it. It could be PDF, JPG, PNG, TIF, BMP, or whatever. I know enough how to tell if the clipboard contains text rather than an image, but if it is an image, I don't know how to tell what kind. I'm using Delphi 2007.

When I say I need to know how to save it, I mean I need to determine if I should use:

ImageEnView1.IO.SaveToFileJpeg(NewFileName);
ImageEnView1.IO.SaveToFilePNG(NewFileName);
ImageEnView1.IO.SaveToFilePDF(NewFileName);

Or something else.

1   L A T E S T    R E P L I E S    (Newest First)
Homer Posted - Dec 15 2021 : 18:20:38
I found the answer. This function returns info about the "copied" file. In my case, there will only be one file in the clipboard, so the following code calls the "GetPasteValue" function. I'm sure you get the idea.

SourceFile := GetPasteValue ;
PastedFileName := ExtractFileName(SourceFile);
SourceExtn := UpperCase(ExtractFileExt(PastedFileName));



Function TfrmMain.GetPasteValue: String;
var
   f: THandle;
   buffer: Array [0..MAX_PATH] of Char;
   i, numFiles: Integer;
   sl: TStringList;
begin
  if Clipboard.HasFormat(CF_HDROP) then
  begin
    sl := TStringList.Create;
    try
      f:= Clipboard.GetAsHandle( CF_HDROP ) ;
      If f <> 0 Then
      Begin
        numFiles := DragQueryFile( f, $FFFFFFFF, nil, 0 ) ;
        sl.Clear;
        for i:= 0 to numfiles - 1 do
        begin
          buffer[0] := #0;
          DragQueryFile( f, i, buffer, sizeof(buffer)) ;
          sl.add( buffer ) ;
        end;
      end;
      if sl.Count > 0 then
         Result := sl.strings[0];

    finally
      Clipboard.close;
      FreeAndNil(sl);
    end;
  end
  else
  Result := 'NO CF_HDROP';
end;