Article View: borland.public.cppbuilder.nativeapi
Article #2045Re: Clipbored and Unicode
From: Bob Gonder
Date: Mon, 14 May 2007 01:04
Date: Mon, 14 May 2007 01:04
49 lines
2698 bytes
2698 bytes
Jos� wrote:
>The clipboard contains text, including Unicode characters. I'm trying
>
> TClipboard *cb=Clipboard();
> cb->Open();
> int TextHandle = cb->GetAsHandle(CF_TEXT);
You want CF_UNICODETEXT for unicode text.
Since that is not a listed format for TClipboard, you might want to
write your own clipboard functions with the WinApi. It's not hard.
> char *pText = (char *)GlobalLock((HGLOBAL)TextHandle);
You need to use the text before you release it.
> GlobalUnlock((HGLOBAL)TextHandle);
> cb->Close();
(You will be doing the same thing above if you use the WinApi.)
You might try this from thr help:
void __fastcall TMainForm::EditPasteClick(TObject* Sender)
{ RichEdit1->PasteFromClipboard();
}
>Again the Unicode characters are replaced by question marks. Perhaps
>this should be expected, since char* has no space for Unicode. But
>what else can I do?
wchar_t is for unicode.
>To write into the clipboard, I found that SetAsHandle (the obvious
>opposite of GetAsHandle) is unusable. It takes an int as second
>parameter, and I want to store a lot more.
It takes a Handle. That is, the same kind of thing you got above:
HGLOBAL h = GlobalAlloc( size, flags );
char * data = GlobalLock( h );
lstrcpy( data, "This goes to the clipboard" );
GlobalUnlock( h );
SetAsHandle( CF_TEXT, h );
// -Do-not- GlobalFree because clipboard owns it.
(You are going to be doing the same thing if you use the WinApi.)
So, it looks like VCL doesn't supprt unicode, which people have been
saying all along. That's ok because you can use the WinApi to do it.
Don't know if the TRichEdit will read it once you get it past the
clipboard though.
Technical Details
Message-ID:
<nqaf43pcont3pe8bdgburrnitj9jiinr68@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<qdde43trid2dep05rjl9pu2k2ohufnguf1@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,eee29c0be9200ce9 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Clipbored and Unicode Date: Sun, 13 May 2007 18:04:22 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <nqaf43pcont3pe8bdgburrnitj9jiinr68@4ax.com> References: <qdde43trid2dep05rjl9pu2k2ohufnguf1@4ax.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 69.69.85.213 X-Trace: newsgroups.borland.com 1179104658 69.69.85.213 (13 May 2007 18:04:18 -0700) Lines: 52 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail