|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 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! |
|
|
|
|
|
|
|
|
|
|