Site icon Learn C++

Easily Learn To Use The Clipboard In Modern C++ On Windows

Clipboard, also called as the paste buffer, is is a buffer which operating systems provide to copy things (texts, bitmaps, tables etc.) for short term and transfer within and between application programs. The clipboard is usually temporary and unnamed, and its contents reside in the computer’s memory.

In C++ Builder, you can use clipboard copy and paste event easily in VCL applications. There is a good example in here http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FMX.CopyPaste_Sample

Let’s summarize some simple VCL and FMX copy and paste operations on texts and on bitmaps.

Using Clipboard in C++ Builder VCL Applications

In C++ Builder VCL applications you must include clipbrd.hpp

[crayon-66066561d3ccf791964668/]

You can copy or paste Text by using clipboard() class as below,

[crayon-66066561d3cd4626754014/]

You can copy or paste Bitmaps by using clipboard() class as below,

[crayon-66066561d3cd6204018268/]

You can do more advanced things by using Clipboard(), There are many components using clipboard properties.

Using Clipboard in C++ Builder FireMonkey Applications

In C++ Builder FMX applications clipboard is available from IFMXClipboardService. There is FMX.clipboard.hpp header you can use.

[crayon-66066561d3cd8088822171/]

In FireMonkey applications you need to use PlatformServices (TPlatformServices) to copy or paste things.

Copying Text to Clipboard

[crayon-66066561d3cd9985562325/]

Copying Image to Clipboard

[crayon-66066561d3cdb219624772/]

Paste Text from Clipboard

[crayon-66066561d3cdd526327774/]

Copying Image to Clipboard

[crayon-66066561d3cdf559216223/]

Find out more about using C++Builder for Windows Apps.

Exit mobile version