Solved

assign multiple objects to the clipboard

Posted on 1997-07-31
2
1,737 Views
Last Modified: 2010-04-04
I want to assign multiple objects to the clipboard, i.e.
bitmaps, records, of any number, and be able to read them all back.  I also want to register my custom clipboard formats with the system when my program is installed.
How do i do this?
0
Comment
Question by:Heapster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
andrewjb earned 200 total points
ID: 1340227
I think the following answers your question, or at least is a start. If there isn't enough here to get you going properly, add a comment, and I'll try to add more.


To assign multiple objects :
Clipboard.Open
Clipboard.SetAsHandle( Type1 , Handle1 )
Clipboard.SetAsHandle( Type2 , Handle2 )
etc.
Clipboard.Close

You can get the data back off the clipboard using GetAsHandle, after testing what is there using the function Clipboard.HasFormat

e.g.

var
  MyFormat : integer;
  MyData   : THandle;

MyFormat := RegisterClipboardFormat( 'Testing' )

...

if ( Clipboard.HasFormat( MyFormat ) ) then
begin
  MyData := Clipboard.GetAsHandle( MyFormat );
end;

You'll need to allocate some global memory with GlobalAlloc / GlobalLock for the handle, and put your data in it.

To register formats :
You need to use the RegisterClipboardFormat function, which returns an integer identifier, or zero on fail
e.g.
MyFirstFormat := RegisterClipboardFormat( 'My clipboard type' );

You can do this wherever you want. ( Doing it twice with the same format description string will return the same integer value )

Units can have an 'initialization' section which is run once only, if the unit is used anywhere in your application. At the end of the implementation section ( after all your functions and procedures ; just before the final end. ) do :

initialization

Type1 := RegisterClipboardFormat( 'First one' );
etc.

End.


0
 
LVL 1

Author Comment

by:Heapster
ID: 1340228
I actually managed to sort this out for myself, so i've
graded your answer as acceptable. Cheers.Paul.
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month6 days, 11 hours left to enroll

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question