How to retrive text that was copied (with the CTRL + C command)
I have a Windows application written in C++. I want to add a paste option, so that on request the application can retrieve whatever text the user previously copied (i.e., with the control-C command).
Is there a way to do this?
You need to use the functions OpenClipboard(), GetClipboardData() and CloseClipboard().
Open the clipboard by calling the OpenClipboard function.
Determine which of the available clipboard formats to retrieve.
Retrieve the handle to the data in the selected format by calling the GetClipboardData function.
Insert a copy of the data into the document.
The handle returned by GetClipboardData is still owned by the clipboard, so an application must not free it or leave it locked.
Close the clipboard by calling the CloseClipboard function.