1 | /* $Id: clipboard.cpp,v 1.8 2000-06-07 14:51:25 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 Clipboard API functions for OS/2
|
---|
5 | *
|
---|
6 | * Copyright 1998 Sander van Leeuwen
|
---|
7 | * Copyright 1998 Patrick Haller
|
---|
8 | * Copyright 1998 Peter Fitzsimmons
|
---|
9 | *
|
---|
10 | *
|
---|
11 | * NOTE: Use OS/2 frame handles for Open32 functions
|
---|
12 | *
|
---|
13 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
14 | *
|
---|
15 | */
|
---|
16 |
|
---|
17 | #include <os2win.h>
|
---|
18 | #include "win32wbase.h"
|
---|
19 |
|
---|
20 | #define DBG_LOCALLOG DBG_clipboard
|
---|
21 | #include "dbglocal.h"
|
---|
22 |
|
---|
23 | //******************************************************************************
|
---|
24 | //******************************************************************************
|
---|
25 | BOOL WIN32API ChangeClipboardChain( HWND hwndRemove, HWND hwndNext)
|
---|
26 | {
|
---|
27 | Win32BaseWindow *wndRemove, *wndNext;
|
---|
28 |
|
---|
29 | wndRemove = Win32BaseWindow::GetWindowFromHandle(hwndRemove);
|
---|
30 | if(!wndRemove) {
|
---|
31 | dprintf(("ChangeClipboardChain, window %x not found", hwndRemove));
|
---|
32 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
33 | return 0;
|
---|
34 | }
|
---|
35 | wndNext = Win32BaseWindow::GetWindowFromHandle(hwndNext);
|
---|
36 | if(!wndNext) {
|
---|
37 | dprintf(("ChangeClipboardChain, window %x not found", hwndNext));
|
---|
38 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
39 | return 0;
|
---|
40 | }
|
---|
41 | dprintf(("USER32: ChangeClipboardChain\n"));
|
---|
42 | return O32_ChangeClipboardChain(wndRemove->getOS2WindowHandle(),
|
---|
43 | wndNext->getOS2WindowHandle());
|
---|
44 | }
|
---|
45 | //******************************************************************************
|
---|
46 | //******************************************************************************
|
---|
47 | BOOL WIN32API CloseClipboard(void)
|
---|
48 | {
|
---|
49 | dprintf(("USER32: CloseClipboard\n"));
|
---|
50 | return O32_CloseClipboard();
|
---|
51 | }
|
---|
52 | //******************************************************************************
|
---|
53 | //******************************************************************************
|
---|
54 | int WIN32API CountClipboardFormats(void)
|
---|
55 | {
|
---|
56 | dprintf(("USER32: CountClipboardFormats\n"));
|
---|
57 | return O32_CountClipboardFormats();
|
---|
58 | }
|
---|
59 | //******************************************************************************
|
---|
60 | //******************************************************************************
|
---|
61 | BOOL WIN32API EmptyClipboard(void)
|
---|
62 | {
|
---|
63 | dprintf(("USER32: EmptyClipboard\n"));
|
---|
64 | return O32_EmptyClipboard();
|
---|
65 | }
|
---|
66 | //******************************************************************************
|
---|
67 | //******************************************************************************
|
---|
68 | UINT WIN32API EnumClipboardFormats(UINT arg1)
|
---|
69 | {
|
---|
70 | dprintf(("USER32: EnumClipboardFormats\n"));
|
---|
71 | return O32_EnumClipboardFormats(arg1);
|
---|
72 | }
|
---|
73 | //******************************************************************************
|
---|
74 | //******************************************************************************
|
---|
75 | HANDLE WIN32API GetClipboardData( UINT arg1)
|
---|
76 | {
|
---|
77 | dprintf(("USER32: GetClipboardData\n"));
|
---|
78 | return O32_GetClipboardData(arg1);
|
---|
79 | }
|
---|
80 | //******************************************************************************
|
---|
81 | //******************************************************************************
|
---|
82 | int WIN32API GetClipboardFormatNameA(UINT format,LPSTR lpszFormatName,int cchMaxCount)
|
---|
83 | {
|
---|
84 | dprintf(("USER32: GetClipboardFormatNameA %d\n",format));
|
---|
85 | return O32_GetClipboardFormatName(format,lpszFormatName,cchMaxCount);
|
---|
86 | }
|
---|
87 | //******************************************************************************
|
---|
88 | //******************************************************************************
|
---|
89 | int WIN32API GetClipboardFormatNameW(UINT format,LPWSTR lpszFormatName,int cchMaxCount)
|
---|
90 | {
|
---|
91 | int rc;
|
---|
92 | char *astring = (CHAR*)malloc(cchMaxCount);
|
---|
93 |
|
---|
94 | dprintf(("USER32: GetClipboardFormatNameW %d\n",format));
|
---|
95 | rc = O32_GetClipboardFormatName(format,astring,cchMaxCount);
|
---|
96 | if (rc) AsciiToUnicode(astring,lpszFormatName);
|
---|
97 | free(astring);
|
---|
98 | return(rc);
|
---|
99 | }
|
---|
100 | //******************************************************************************
|
---|
101 | //******************************************************************************
|
---|
102 | HWND WIN32API GetClipboardOwner(void)
|
---|
103 | {
|
---|
104 | HWND hwndOwner;
|
---|
105 | Win32BaseWindow *window;
|
---|
106 |
|
---|
107 | dprintf(("USER32: GetClipboardOwner\n"));
|
---|
108 | hwndOwner = O32_GetClipboardOwner();
|
---|
109 |
|
---|
110 | window = Win32BaseWindow::GetWindowFromOS2Handle(hwndOwner);
|
---|
111 | if(!window) {
|
---|
112 | //an OS/2 window probably owns the clipboard, we pretend nobody owns it
|
---|
113 | return NULL;
|
---|
114 | }
|
---|
115 | return window->getWindowHandle();
|
---|
116 | }
|
---|
117 | //******************************************************************************
|
---|
118 | //******************************************************************************
|
---|
119 | HWND WIN32API GetClipboardViewer(void)
|
---|
120 | {
|
---|
121 | Win32BaseWindow *window;
|
---|
122 | HWND hwndViewer;
|
---|
123 |
|
---|
124 | dprintf(("USER32: GetClipboardViewer\n"));
|
---|
125 | hwndViewer = O32_GetClipboardViewer();
|
---|
126 |
|
---|
127 | window = Win32BaseWindow::GetWindowFromOS2Handle(hwndViewer);
|
---|
128 | if(!window) {
|
---|
129 | //probably an OS/2 window, we pretend it's nobody
|
---|
130 | return NULL;
|
---|
131 | }
|
---|
132 | return window->getWindowHandle();
|
---|
133 | }
|
---|
134 | //******************************************************************************
|
---|
135 | //******************************************************************************
|
---|
136 | HWND WIN32API GetOpenClipboardWindow(void)
|
---|
137 | {
|
---|
138 | Win32BaseWindow *window;
|
---|
139 | HWND hwnd;
|
---|
140 |
|
---|
141 | dprintf(("USER32: GetOpenClipboardWindow\n"));
|
---|
142 | hwnd = O32_GetOpenClipboardWindow();
|
---|
143 |
|
---|
144 | window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
---|
145 | if(!window) {
|
---|
146 | //probably an OS/2 window, we pretend it's nobody
|
---|
147 | return NULL;
|
---|
148 | }
|
---|
149 | return window->getWindowHandle();
|
---|
150 | }
|
---|
151 | //******************************************************************************
|
---|
152 | //******************************************************************************
|
---|
153 | int WIN32API GetPriorityClipboardFormat( PUINT arg1, int arg2)
|
---|
154 | {
|
---|
155 | dprintf(("USER32: GetPriorityClipboardFormat\n"));
|
---|
156 | return O32_GetPriorityClipboardFormat(arg1, arg2);
|
---|
157 | }
|
---|
158 | //******************************************************************************
|
---|
159 | //******************************************************************************
|
---|
160 | BOOL WIN32API IsClipboardFormatAvailable( UINT arg1)
|
---|
161 | {
|
---|
162 | dprintf(("USER32: IsClipboardFormatAvailable\n"));
|
---|
163 | return O32_IsClipboardFormatAvailable(arg1);
|
---|
164 | }
|
---|
165 | //******************************************************************************
|
---|
166 | //******************************************************************************
|
---|
167 | BOOL WIN32API OpenClipboard( HWND hwnd)
|
---|
168 | {
|
---|
169 | Win32BaseWindow *window;
|
---|
170 |
|
---|
171 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
172 | if(!window) {
|
---|
173 | dprintf(("OpenClipboard, window %x not found", hwnd));
|
---|
174 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
175 | return 0;
|
---|
176 | }
|
---|
177 | dprintf(("USER32: OpenClipboard\n"));
|
---|
178 | return O32_OpenClipboard(window->getOS2WindowHandle());
|
---|
179 | }
|
---|
180 | //******************************************************************************
|
---|
181 | //******************************************************************************
|
---|
182 | UINT WIN32API RegisterClipboardFormatA( LPCSTR arg1)
|
---|
183 | {
|
---|
184 | dprintf(("USER32: RegisterClipboardFormatA %s", arg1));
|
---|
185 | return O32_RegisterClipboardFormat(arg1);
|
---|
186 | }
|
---|
187 | //******************************************************************************
|
---|
188 | //******************************************************************************
|
---|
189 | UINT WIN32API RegisterClipboardFormatW(LPCWSTR arg1)
|
---|
190 | {
|
---|
191 | UINT rc;
|
---|
192 | char *astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
193 |
|
---|
194 | dprintf(("USER32: RegisterClipboardFormatW %s\n", astring));
|
---|
195 | rc = O32_RegisterClipboardFormat(astring);
|
---|
196 | FreeAsciiString(astring);
|
---|
197 | dprintf(("USER32: RegisterClipboardFormatW returned %d\n", rc));
|
---|
198 | return(rc);
|
---|
199 | }
|
---|
200 | //******************************************************************************
|
---|
201 | //******************************************************************************
|
---|
202 | HANDLE WIN32API SetClipboardData( UINT arg1, HANDLE arg2)
|
---|
203 | {
|
---|
204 | dprintf(("USER32: SetClipboardData\n"));
|
---|
205 | return O32_SetClipboardData(arg1, arg2);
|
---|
206 | }
|
---|
207 | //******************************************************************************
|
---|
208 | //******************************************************************************
|
---|
209 | HWND WIN32API SetClipboardViewer( HWND hwndNew)
|
---|
210 | {
|
---|
211 | Win32BaseWindow *wndnew, *wndold;
|
---|
212 | HWND hwndOld;
|
---|
213 |
|
---|
214 | wndnew = Win32BaseWindow::GetWindowFromHandle(hwndNew);
|
---|
215 | if(!wndnew) {
|
---|
216 | dprintf(("OpenClipboard, window %x not found", hwndNew));
|
---|
217 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
218 | return 0;
|
---|
219 | }
|
---|
220 | dprintf(("USER32: SetClipboardViewer\n"));
|
---|
221 | hwndOld = O32_SetClipboardViewer(wndnew->getOS2WindowHandle());
|
---|
222 |
|
---|
223 | wndold = Win32BaseWindow::GetWindowFromOS2Handle(hwndOld);
|
---|
224 | if(!wndold) {
|
---|
225 | //probably an OS/2 window, so pretend it's nobody
|
---|
226 | return 0;
|
---|
227 | }
|
---|
228 | return wndold->getWindowHandle();
|
---|
229 | }
|
---|
230 | //******************************************************************************
|
---|
231 | //******************************************************************************
|
---|