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