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
 How to add specific custom information to Clipboard

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
PeterPanino Posted - Jul 15 2021 : 08:44:41
From a TIEBitmap, I copy to the clipboard with this code:

MyIEBitmap.CopyToClipboard(True, True);


Together with this copy action, is it possible to additionally add some unique ID to the clipboard content, for example:

• A specific custom Clipboard Format?
• A specific textual information inside the clipboard "IMAGEEN RAW FORMAT"?

The purpose is: I need to unambiguously identify the clipboard content created with the above copy action.

PS: Please allow longer posting titles.
4   L A T E S T    R E P L I E S    (Newest First)
PeterPanino Posted - Jul 16 2021 : 05:36:17
Hi Nigel

Thank you for lifting the subject length limitation.

I have tested with several applications (including my own app that uses ImageEn): None of them has a problem with pasting a clipboard image with an additional text format on the clipboard.
xequte Posted - Jul 15 2021 : 19:26:08
Hi Peter

If you copy a layer (image), then its associated meta-data is copied. This is not done for bitmap raw format.

You might want to create your own clipboard format to handle it (raw image + string). There will be examples on the internet to do this. The code in your final example may work as long as you are the only one to use the clipboard data (i.e. cannot guarantee how third party apps will perform when there is both text and an image on the clipboard).

I've lifted the subject length limitation.

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Jul 15 2021 : 12:04:50
This seems to work:

Clipboard.Open;
try
  Clipboard.Assign(MyIEBitmap.VclBitmap);
  Clipboard.AsText := 'MyUniqueID';
finally
  Clipboard.Close;
end;


Is this correct and can this be optimized?
PeterPanino Posted - Jul 15 2021 : 10:28:16
I've tried this workaround, but it does not work and even blocks MyIEBitmap.CopyToClipboard to copy to the clipboard:

procedure SetBuffer(Format: Word; const Buffer; Size: Integer);
var
  DataPtr: Pointer;
  Data: THandle;
begin
  Data := GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE, Size);
  try
    DataPtr := GlobalLock(Data);
    try
      Move(Buffer, DataPtr^, Size);
      Win32Check(SetClipboardData(Format, Data) <> 0);
    finally
      GlobalUnlock(Data);
    end;
  except
    GlobalFree(Data);
    raise;
  end;
end;

Clipboard.Open;
try
  MyIEBitmap.CopyToClipboard(True, True);
  const ThisID: string = 'UniqueID';
  SetBuffer(CF_UNICODETEXT, Text[1], ByteLength(ThisID));
finally
  Clipboard.Close;
end;