/[pearpc]/src/system/osapi/win32/sysclipboard.cc
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /src/system/osapi/win32/sysclipboard.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Wed Sep 5 17:11:21 2007 UTC (16 years, 6 months ago) by dpavlin
File size: 1767 byte(s)
import upstream CVS
1 /*
2 * PearPC
3 * clipboard.cc - Win32-specific (windows-)clipboard functions
4 *
5 * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net)
6 * Copyright (C) 1999-2002 Stefan Weyergraf
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #define WIN32_LEAN_AND_MEAN
23 #include <windows.h>
24
25 #define MIN(a,b) (((a)<(b))?(a):(b))
26 bool sys_write_data_to_native_clipboard(const void *data, int size)
27 {
28 // FIXME:
29 if (!OpenClipboard(0)) return false;
30 HGLOBAL hdata;
31 hdata = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, size);
32 if (hdata) {
33 void *ptr = GlobalLock(hdata);
34 memmove(ptr, data, size);
35 GlobalUnlock(hdata);
36 if (SetClipboardData(CF_OEMTEXT, hdata)) {
37 CloseClipboard();
38 return true;
39 }
40 }
41 CloseClipboard();
42 return false;
43 }
44
45 int sys_get_native_clipboard_data_size()
46 {
47 return 0;
48 }
49
50 bool sys_read_data_from_native_clipboard(void *data, int max_size)
51 {
52 if (!OpenClipboard(0)) return false;
53 HANDLE hdata = GetClipboardData(CF_OEMTEXT);
54 if (!hdata) {
55 CloseClipboard();
56 return false;
57 }
58 int size = GlobalSize(hdata);
59 void *ptr = GlobalLock(hdata);
60 memmove(data, ptr, MIN(size, max_size));
61 GlobalUnlock(hdata);
62 CloseClipboard();
63 return true;
64 }
65

  ViewVC Help
Powered by ViewVC 1.1.26