Majerus,
Fri Dec 03 07:44:34 CST 2004
>I want to copy something to clipboard,
> and bellow codes work well in Win32,
> but don't work in WinCE.
> any tip or suggestion would of great help.
> Thank you in advanced.
>
>>CString strData = L"Line 1\nLine 2\nLine 3";
>>OpenClipboard();
>>EmptyClipboard();
>>HGLOBAL hClipboardData;
>>TCHAR *pchData;
>>hClipboardData = GlobalAlloc(GPTR, lstrlen(strData)+1);
>>pchData = (TCHAR*)GlobalLock(hClipboardData);
>>memcpy(pchData, strData, lstrlen(strData)+1);
>>GlobalUnlock(hClipboardData);
>>::SetClipboardData( CF_TEXT, hClipboardData );
>>CloseClipboard();
Posting 3 times will not get you an answer 3 times faster, usually more like
3 times slower as it's considered rude.
If you actually tried to compile that code, you should have seen that
GlobalAlloc doesn't exists in CE, and that the documentation for
SetClipboardData states the following:
----->
After SetClipboardData is called, the system owns the object identified by
the hMem parameter. The application can read the data, but must not free the
handle or leave it locked. If the hMem parameter identifies a memory object,
the object must have been allocated using the LocalAlloc function.
<-----
Reading the documentation for APIs you call can be usefull, they might look
like NT and yet have some important differences.
--
Philippe Majerus
Microsoft MVP - Mobile Devices (
http://support.microsoft.com/support/mvp)
Software, Documentation and stuff -
http://www.phm.lu