Clipboard paste error code
csitGenny opened this issue · 0 comments
Non English programs, clipboard paste error code solution:
-
Move "#include <Clipbrd.hpp>" from "Misc.cpp" to "Misc.h"
-
In Misc.h add:
//Add by ZGL--------------------------------------------------------------
class TUnicodeClipboard : public TClipboard
{
private:
WideString __fastcall GetAsUnicodeText();
void __fastcall SetAsUnicodeText(const WideString Value);
public:
__property WideString AsUnicodeText = {read=GetAsUnicodeText, write=SetAsUnicodeText};
};
//--------------------------------------------------------------------------- -
In Misc.cpp add:
//Add by ZGL--------------------------------------------------------------
WideString __fastcall TUnicodeClipboard::GetAsUnicodeText()
{
WideString res;
Open();
HANDLE data = GetClipboardData(CF_UNICODETEXT);
try
{
if (data)
res = (wchar_t *)GlobalLock(data);
else
res = "";
}
__finally
{
if (data) GlobalUnlock(data);
Close();
}
return res;
}
//Add by ZGL----------------------------------------------------------------
void __fastcall TUnicodeClipboard::SetAsUnicodeText(const WideString Value)
{
SetBuffer(CF_UNICODETEXT, (wchar_t *)Value, (wcslen(Value) + 1) * sizeof(WideChar));
}
//--------------------------------------------------------------------------- -
Then, all "Clipboard()->AsText =" in the program are changed to:
“((TUnicodeClipboard *)Clipboard())->AsUnicodeText =”;
All "Clipboard()->SetTextBuf (??)" are changed to:
"((TUnicodeClipboard *)Clipboard())->AsUnicodeText =??"