Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7447505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:37:22+00:00 2026-05-29T12:37:22+00:00

Is it possible, and if so how would you go about implementing your own

  • 0

Is it possible, and if so how would you go about implementing your own clipboard?

By this I mean be able to Copy and Paste anything to and from it just like the Windows clipboard does, but without actually interfering with the system clipboard.

To give a better idea this is what I tried:

uses
  ClipBrd;

...

procedure TMainForm.actCopyExecute(Sender: TObject);
var
  MyClipboard: TClipboard;
begin
  MyClipboard := TClipboard.Create;
  try
    MyClipboard.AsText := 'Copy this text';
  finally
    MyClipboard.Free;
  end;
end;

That works in that it will copy the string “Copy this text” to the clipboard, but it overwrites whatever was on the Windows clipboard.

The above must just create an instance of the Windows clipboard, not actually creating your own.

Note that the custom clipboard could hold any data not just plain text. It should work just the same as the Windows clipboard, but without interfering with it (losing whatever was on it).

How could this be achieved?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:37:23+00:00Added an answer on May 29, 2026 at 12:37 pm

    Your question is confusing; you say you want to do it without affecting the system clipboard, but then (from your own comment to your question) you seem to be wanting to implement something like MS Office’s Paste Special.

    If it’s the first, as others have said you can’t do that using the TClipboard wrapper; you have to implement your own, and passing information between applications will be very difficult.

    If it’s the second, you do this by using the Windows API RegisterClipboardFormat to define your own format.

    type
      TForm1=class(TForm)
        YourCustomFormat: Word;
        procedure FormCreate(Sender: TObject);
      end;
    
    implementation
    
    constructor TForm1.FormCreate(Sender: TObject);
    begin
      YourCustomFormat := RegisterClipboardFormat('Your Custom Format Name');
    end;
    

    To put info into the clipboard in a custom format, you have to use GlobalAlloc and GlobalLock to allocate and lock a global memory block, copy your data into that block, unlock the block using GlobalUnlock, use TClipboard.SetAsHandle to transfer the memory block into the clipboard. You then need to then call GlobalFree to free the memory block.

    To retrieve things in your custom format, you do basically the same thing with a couple of steps reversed. You use GlobalAlloc/GlobalLock as before, use TClipboard.GetAsHandle to retrieve the clipboard’s content, copy it into a local variable, and then call GlobalFree.

    Here’s an old example of putting a custom format (in this case, RTF text) into the clipboard – it’s from a newsgroup post by Dr. Peter Below of TeamB. (The code and formatting are his from the original post; I’ve not tested it or even compiled it.) Reversing the process to get it back out should be clear from my instructions on what to change above, and I leave that to you to work out. 🙂

    procedure TForm1.BtnSetRTFClick(Sender: TObject);
    Const
      testtext: PChar = '{\rtf1\ansi\pard\plain 12{\ul 44444}}';
      testtext2: PChar = '{\rtf1\ansi'+
      '\deff4\deflang1033{\fonttbl{\f4\froman\fcharset0\fprq2 Times New Roman;}}'
                         +'\pard\plain 12{\ul 44444}}';
      flap: Boolean = False;
    Var
      MemHandle: THandle;
      rtfstring: PChar;
    begin
        If flap Then
          rtfstring := testtext2
        Else
          rtfstring := testtext;
        flap := not flap;
        MemHandle := GlobalAlloc( GHND or GMEM_SHARE, StrLen(rtfstring)+1 );
        If MemHandle <> 0 Then Begin
          try
            StrCopy( GlobalLock( MemHandle ), rtfstring );
            GlobalUnlock( MemHandle );
            With Clipboard Do Begin
              Open;
              try
                AsText := '1244444';
                SetAsHandle( CF_RTF, MemHandle );
              finally
                Close;
              end;
            End;
          Finally
            GlobalFree( MemHandle );
          End;
        End
        Else
          MessageDlg('Global Alloc failed!',
                     mtError, [mbOK], 0 );
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I go about generating a list of all possible permutations of a
Hey, I'm just wondering if it would be possible to convert videos to mp3
How would it be possible to capture the audio programmatically? I am implementing an
Any other tweaks for making emacs as vim-like as possible would be appreciated as
Possible Duplicates: How would I implement stackoverflow’s hovering dialogs? i want a small box
Possible Duplicate: How would you count occurences of a string within a string (C#)?
I was wondering if it would be possible to retrieve the complete list of
Question So I've recently came up with some new possible projects that would have
How would it be possible to have a HTML page play a flash animation
Possible Duplicate: What WPF books would you recommend? GUI's written using WPF seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.