1 | /* $Id: clipboard.cpp,v 1.5 2000-02-16 14:34:06 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->getOS2FrameWindowHandle(),
|
---|
43 | wndNext->getOS2FrameWindowHandle());
|
---|
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 arg1, LPSTR arg2, int arg3)
|
---|
83 | {
|
---|
84 | dprintf(("USER32: GetClipboardFormatNameA %s\n", arg2));
|
---|
85 | return O32_GetClipboardFormatName(arg1, arg2, arg3);
|
---|
86 | }
|
---|
87 | //******************************************************************************
|
---|
88 | //******************************************************************************
|
---|
89 | int WIN32API GetClipboardFormatNameW(UINT arg1, LPWSTR arg2, int arg3)
|
---|
90 | {
|
---|
91 | int rc;
|
---|
92 | char *astring = UnicodeToAsciiString(arg2);
|
---|
93 |
|
---|
94 | dprintf(("USER32: GetClipboardFormatNameW %s\n", astring));
|
---|
95 | rc = O32_GetClipboardFormatName(arg1, astring, arg3);
|
---|
96 | FreeAsciiString(astring);
|
---|
97 | return(rc);
|
---|
98 | }
|
---|
99 | //******************************************************************************
|
---|
100 | //******************************************************************************
|
---|
101 | HWND WIN32API GetClipboardOwner(void)
|
---|
102 | {
|
---|
103 | HWND hwndOwner;
|
---|
104 | Win32BaseWindow *window;
|
---|
105 |
|
---|
106 | dprintf(("USER32: GetClipboardOwner\n"));
|
---|
107 | hwndOwner = O32_GetClipboardOwner();
|
---|
108 |
|
---|
109 | window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndOwner);
|
---|
110 | if(!window) {
|
---|
111 | //an OS/2 window probably owns the clipboard, we pretend nobody owns it
|
---|
112 | return NULL;
|
---|
113 | }
|
---|
114 | return window->getWindowHandle();
|
---|
115 | }
|
---|
116 | //******************************************************************************
|
---|
117 | //******************************************************************************
|
---|
118 | HWND WIN32API GetClipboardViewer(void)
|
---|
119 | {
|
---|
120 | Win32BaseWindow *window;
|
---|
121 | HWND hwndViewer;
|
---|
122 |
|
---|
123 | dprintf(("USER32: GetClipboardViewer\n"));
|
---|
124 | hwndViewer = O32_GetClipboardViewer();
|
---|
125 |
|
---|
126 | window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndViewer);
|
---|
127 | if(!window) {
|
---|
128 | //probably an OS/2 window, we pretend it's nobody
|
---|
129 | return NULL;
|
---|
130 | }
|
---|
131 | return window->getWindowHandle();
|
---|
132 | }
|
---|
133 | //******************************************************************************
|
---|
134 | //******************************************************************************
|
---|
135 | HWND WIN32API GetOpenClipboardWindow(void)
|
---|
136 | {
|
---|
137 | Win32BaseWindow *window;
|
---|
138 | HWND hwnd;
|
---|
139 |
|
---|
140 | dprintf(("USER32: GetOpenClipboardWindow\n"));
|
---|
141 | hwnd = O32_GetOpenClipboardWindow();
|
---|
142 |
|
---|
143 | window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
|
---|
144 | if(!window) {
|
---|
145 | //probably an OS/2 window, we pretend it's nobody
|
---|
146 | return NULL;
|
---|
147 | }
|
---|
148 | return window->getWindowHandle();
|
---|
149 | }
|
---|
150 | //******************************************************************************
|
---|
151 | //******************************************************************************
|
---|
152 | int WIN32API GetPriorityClipboardFormat( PUINT arg1, int arg2)
|
---|
153 | {
|
---|
154 | dprintf(("USER32: GetPriorityClipboardFormat\n"));
|
---|
155 | return O32_GetPriorityClipboardFormat(arg1, arg2);
|
---|
156 | }
|
---|
157 | //******************************************************************************
|
---|
158 | //******************************************************************************
|
---|
159 | BOOL WIN32API IsClipboardFormatAvailable( UINT arg1)
|
---|
160 | {
|
---|
161 | dprintf(("USER32: IsClipboardFormatAvailable\n"));
|
---|
162 | return O32_IsClipboardFormatAvailable(arg1);
|
---|
163 | }
|
---|
164 | //******************************************************************************
|
---|
165 | //******************************************************************************
|
---|
166 | BOOL WIN32API OpenClipboard( HWND hwnd)
|
---|
167 | {
|
---|
168 | Win32BaseWindow *window;
|
---|
169 |
|
---|
170 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
171 | if(!window) {
|
---|
172 | dprintf(("OpenClipboard, window %x not found", hwnd));
|
---|
173 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
174 | return 0;
|
---|
175 | }
|
---|
176 | dprintf(("USER32: OpenClipboard\n"));
|
---|
177 | return O32_OpenClipboard(window->getOS2FrameWindowHandle());
|
---|
178 | }
|
---|
179 | //******************************************************************************
|
---|
180 | //******************************************************************************
|
---|
181 | UINT WIN32API RegisterClipboardFormatA( LPCSTR arg1)
|
---|
182 | {
|
---|
183 | dprintf(("USER32: RegisterClipboardFormatA\n"));
|
---|
184 | return O32_RegisterClipboardFormat(arg1);
|
---|
185 | }
|
---|
186 | //******************************************************************************
|
---|
187 | //******************************************************************************
|
---|
188 | UINT WIN32API RegisterClipboardFormatW(LPCWSTR arg1)
|
---|
189 | {
|
---|
190 | UINT rc;
|
---|
191 | char *astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
192 |
|
---|
193 | dprintf(("USER32: RegisterClipboardFormatW %s\n", astring));
|
---|
194 | rc = O32_RegisterClipboardFormat(astring);
|
---|
195 | FreeAsciiString(astring);
|
---|
196 | dprintf(("USER32: RegisterClipboardFormatW returned %d\n", rc));
|
---|
197 | return(rc);
|
---|
198 | }
|
---|
199 | //******************************************************************************
|
---|
200 | //******************************************************************************
|
---|
201 | HANDLE WIN32API SetClipboardData( UINT arg1, HANDLE arg2)
|
---|
202 | {
|
---|
203 | dprintf(("USER32: SetClipboardData\n"));
|
---|
204 | return O32_SetClipboardData(arg1, arg2);
|
---|
205 | }
|
---|
206 | //******************************************************************************
|
---|
207 | //******************************************************************************
|
---|
208 | HWND WIN32API SetClipboardViewer( HWND hwndNew)
|
---|
209 | {
|
---|
210 | Win32BaseWindow *wndnew, *wndold;
|
---|
211 | HWND hwndOld;
|
---|
212 |
|
---|
213 | wndnew = Win32BaseWindow::GetWindowFromHandle(hwndNew);
|
---|
214 | if(!wndnew) {
|
---|
215 | dprintf(("OpenClipboard, window %x not found", hwndNew));
|
---|
216 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
217 | return 0;
|
---|
218 | }
|
---|
219 | dprintf(("USER32: SetClipboardViewer\n"));
|
---|
220 | hwndOld = O32_SetClipboardViewer(wndnew->getOS2FrameWindowHandle());
|
---|
221 |
|
---|
222 | wndold = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndOld);
|
---|
223 | if(!wndold) {
|
---|
224 | //probably an OS/2 window, so pretend it's nobody
|
---|
225 | return 0;
|
---|
226 | }
|
---|
227 | return wndold->getWindowHandle();
|
---|
228 | }
|
---|
229 | //******************************************************************************
|
---|
230 | //******************************************************************************
|
---|