Search Pocket PC Life's 126 Pocket PC-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Freeing up DLLs, avoiding suspend mode, and listbox tricks (continued)

Also, the desktop requires that the data being put on the clipboard be allocated with GlobalAlloc. Windows CE doesn't support GlobalAlloc, so LocalAlloc with the LMEM_MOVEABLE flag should be used.

The following code snippet shows how to work around Windows CE's shortcomings and put the clipboard APIs to work:

/*
Put a text buffer on the clipboard
*/
BOOL PutTextOnClipboard(HWND hwnd, LPTSTR pszText)
{
BOOL bSuccess = FALSE;

if ( IsWindow(hwnd) && OpenClipboard(hwnd) )
{
EmptyClipboard();

LPTSTR pszCopy = (LPTSTR)LocalAlloc(LMEM_MOVEABLE, (_tcslen(pszText)+1) * sizeof(TCHAR));

if ( pszCopy )
{
_tcscpy(pszCopy, pszText);

UINT uiFormat;
#ifdef UNICODE
uiFormat = CF_UNICODETEXT;
#else
uiFormat = CF_TEXT;
#endif
bSuccess = (SetClipboardData(uiFormat, pszCopy) != NULL);

// if the clipboard doesn't own the data, we need to free it
if ( bSuccess == FALSE )
LocalFree(pszCopy);
}

CloseClipboard();
}

return bSuccess;
}

That's all we have room for this month. I look forward to hearing about what ails you (regarding development for CE, that is), at poweranswers@bsquare.com.

Andrew Tucker works on developer tools for Windows CE at bSQUARE Corporation. He has been writing code for Windows since 1991 and has published articles in C/C++ Users Journal, Dr Dobbs Journal, and Windows Developer Journal. He recently co-authored SAMS Teach Yourself Windows CE Programming in 24 Hours. Andrew has a BSCS from Seattle Pacific University and is working on a MSCS at the University of Washington. He can be reached at poweranswers@bsquare.com.


« Previous  ·  1  ·  2  ·  3  ·  4
Other articles you might like
Home > Phones and PDAs > Windows Mobile > Programming (3 articles)
   HP hotkeys, OK buttons, and file existence
   Palm-sized input panel quirks and mounted database volumes
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
More from the ZATZ journals
Computing Unplugged: Smartphone smarts for a mobile world
David Gewirtz Online: CNN commentary and analysis
DominoPower: It's time for Lotus to double-down on Linux and open source
OutlookPower: The strange case of Outlook losing notes and requiring passwords
-- Advertisement --

EASY DEDICATED AND VIRTUAL DEDICATED SERVERS FOR AS LOW AS $67.99 PER MONTH
Customize and configure your own dedicated server. Simply choose one of our popular plans or select your own Linux or Windows server and plan options.

NO LONG WAITS. Server provisioned within hours.

Tap here now and be up and running with your own server tonight.

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1999-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login