🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #13067

Content missing when using clipboard API calls

#13067
From: Kris
Date: Sat, 25 Oct 2003 07:41
32 lines
2130 bytes
Hi,

When executing the code below and putting the data contained in
TEXT_ClipboardData (which is "PLAIN TEXT SAMPLE") I will only get
"PLAIN TEXT SAMPL" (i.e. the last char is missing).

Now, I'm currently using String.Length to determine the size of the
memory buffer that will be passed on to the clipboard. And because of
that I won't be copying the terminating zero of the string to the
clipboard (don't really know if this is really necessary anyway ?).

Nevertheless, even with .Length() as buffersize the last character of
the string (being the 'E') does get copied to the clipboardbuffer but
does NOT appear when I paste the clipboardbuffer.

Sure, I can really easily solve this by making the buffer just 1 byte
longer but I really would like to know why this is happening ?

Thanks,

HGLOBAL TEXT_hglbCopy;
String TEXT_ClipboardData="PLAIN TEXT SAMPLE";
// Take care of plain text format
TEXT_hglbCopy= GlobalAlloc(GMEM_MOVEABLE,TEXT_ClipboardData.Length());
if (TEXT_hglbCopy!=NULL)
{
   TEXT_lptstrCopy=(char*)GlobalLock(TEXT_hglbCopy);

memcpy(TEXT_lptstrCopy,TEXT_ClipboardData.c_str(),TEXT_ClipboardData.Length());
   SetClipboardData(CF_TEXT,TEXT_hglbCopy);
   GlobalUnlock(TEXT_hglbCopy);
}
Technical Details
Message-ID: <cq9kpv03v7gookvn5ao482qv0bl7352eva@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,8c9761db6f386d91,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-25 00:50:21 PST
From: Kris <myEmail@email.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Content missing when using clipboard API calls
Date: Sat, 25 Oct 2003 09:41:38 +0200
Message-ID: <cq9kpv03v7gookvn5ao482qv0bl7352eva@4ax.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 81.11.139.96
X-Trace: newsgroups.borland.com 1067067691 81.11.139.96 (25 Oct 2003 00:41:31 -0700)
Lines: 34
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail