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: Make Mafia Wars an offer it can't refuse
David Gewirtz Online: CNN commentary and analysis
DominoPower: Application development, William Shatner, and the origin of the universe
OutlookPower: Removing an Office installation that doesn't want to go away
-- Advertisement --

ONLINE GROUP CALENDAR - FOR UP TO 100 OF YOUR CLOSEST FRIENDS
Stay organized and in control with 24/7 access to all of your important events, projects and files --whether you're at work, at home or on the road.

You can share your calendar, projects and files so everyone in your office is up to date. Plus, search your entire group to find times when everyone is available to meet, manage company resources and much more.

Organize your entire team for as low as $9.95 per year (and yes, that's where the decimal place is supposed to be!)

Tap here to get started right away.

-- Advertisement --

Write for Computing Unplugged!
Share your experience and expertise with other handheld device users. There are new opportunities at ZATZ for contributing authors and editors.

Write about something you're an expert on and get your name in lights.

For Writers' Guidelines and to discuss topics, contact Staff Editor Steve Niles. This is your opportunity to shine in front of your peers, your clients, and friends.

Click for more info!

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