crypto2011/IDR

Clipboard paste error code

csitGenny opened this issue · 0 comments

Non English programs, clipboard paste error code solution:

  1. Move "#include <Clipbrd.hpp>" from "Misc.cpp" to "Misc.h"

  2. 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};
    };
    //---------------------------------------------------------------------------

  3. 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));
    }
    //---------------------------------------------------------------------------

  4. Then, all "Clipboard()->AsText =" in the program are changed to:
    “((TUnicodeClipboard *)Clipboard())->AsUnicodeText =”;

All "Clipboard()->SetTextBuf (??)" are changed to:
"((TUnicodeClipboard *)Clipboard())->AsUnicodeText =??"