Reputation: 1791
My copy code:
if OpenClipboard(mainwnd.Handle) then
MemHandle := GlobalAlloc(GHND or GMEM_SHARE, Succ(StrLen(pLclCopies)));
if MemHandle <> 0 Then
Begin
try
StrCopy(GlobalLock(MemHandle), pLclCopies);
GlobalUnlock(MemHandle);
SetClipboardData(cf_LocalVar,MemHandle);
Finally
CloseClipboard;
GlobalFree(MemHandle);
end;
end;
and my paste code:
if clipboard.HasFormat(cf_LocalVar) then
begin
ClipBoard.Open;
try
MyHandle := Clipboard.GetAsHandle(cf_LocalVar);
LocalsTextPtr := GlobalLock(MyHandle);
CheckForCopiedLocals(LocalsTextPtr, TextPtr); //What I do with the pasted data.
GlobalUnLock(MyHandle);
finally
Clipboard.Close;
end;
end;
My goal is to copy not only text from a special editor in my program, but also to copy some underlying variable data related to that editor. Most everything seems to be working fine clipboard wise - I'm seeing my copied text, and the 'cf_LocalVar' format appear in the ClipBook viewer on windows.
It's when I get to the paste side and the line
LocalsTextPtr := GlobalLock(MyHandle);
doesn't get the copied data from the first bit of code. I see that it makes it into pLclCopies but then can't be sure that it's stored in the clipboard.
NB I have left out emptyclipboard from my code as this would get rid of the cf_text that I need along with the cf_LocalVar.
Upvotes: 0
Views: 139