| 1 | /* $Id: clipboard.cpp,v 1.9 2000-11-15 20:30:45 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 | if (hwnd) {
|
|---|
| 172 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 173 | if(!window) {
|
|---|
| 174 | dprintf(("OpenClipboard, window %x not found", hwnd));
|
|---|
| 175 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 176 | return 0;
|
|---|
| 177 | }
|
|---|
| 178 | }
|
|---|
| 179 | dprintf(("USER32: OpenClipboard\n"));
|
|---|
| 180 | return O32_OpenClipboard(hwnd ? window->getOS2WindowHandle() : NULL);
|
|---|
| 181 | }
|
|---|
| 182 | //******************************************************************************
|
|---|
| 183 | //******************************************************************************
|
|---|
| 184 | UINT WIN32API RegisterClipboardFormatA( LPCSTR arg1)
|
|---|
| 185 | {
|
|---|
| 186 | dprintf(("USER32: RegisterClipboardFormatA %s", arg1));
|
|---|
| 187 | return O32_RegisterClipboardFormat(arg1);
|
|---|
| 188 | }
|
|---|
| 189 | //******************************************************************************
|
|---|
| 190 | //******************************************************************************
|
|---|
| 191 | UINT WIN32API RegisterClipboardFormatW(LPCWSTR arg1)
|
|---|
| 192 | {
|
|---|
| 193 | UINT rc;
|
|---|
| 194 | char *astring = UnicodeToAsciiString((LPWSTR)arg1);
|
|---|
| 195 |
|
|---|
| 196 | dprintf(("USER32: RegisterClipboardFormatW %s\n", astring));
|
|---|
| 197 | rc = O32_RegisterClipboardFormat(astring);
|
|---|
| 198 | FreeAsciiString(astring);
|
|---|
| 199 | dprintf(("USER32: RegisterClipboardFormatW returned %d\n", rc));
|
|---|
| 200 | return(rc);
|
|---|
| 201 | }
|
|---|
| 202 | //******************************************************************************
|
|---|
| 203 | //******************************************************************************
|
|---|
| 204 | HANDLE WIN32API SetClipboardData( UINT arg1, HANDLE arg2)
|
|---|
| 205 | {
|
|---|
| 206 | dprintf(("USER32: SetClipboardData\n"));
|
|---|
| 207 | return O32_SetClipboardData(arg1, arg2);
|
|---|
| 208 | }
|
|---|
| 209 | //******************************************************************************
|
|---|
| 210 | //******************************************************************************
|
|---|
| 211 | HWND WIN32API SetClipboardViewer( HWND hwndNew)
|
|---|
| 212 | {
|
|---|
| 213 | Win32BaseWindow *wndnew, *wndold;
|
|---|
| 214 | HWND hwndOld;
|
|---|
| 215 |
|
|---|
| 216 | wndnew = Win32BaseWindow::GetWindowFromHandle(hwndNew);
|
|---|
| 217 | if(!wndnew) {
|
|---|
| 218 | dprintf(("OpenClipboard, window %x not found", hwndNew));
|
|---|
| 219 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 220 | return 0;
|
|---|
| 221 | }
|
|---|
| 222 | dprintf(("USER32: SetClipboardViewer\n"));
|
|---|
| 223 | hwndOld = O32_SetClipboardViewer(wndnew->getOS2WindowHandle());
|
|---|
| 224 |
|
|---|
| 225 | wndold = Win32BaseWindow::GetWindowFromOS2Handle(hwndOld);
|
|---|
| 226 | if(!wndold) {
|
|---|
| 227 | //probably an OS/2 window, so pretend it's nobody
|
|---|
| 228 | return 0;
|
|---|
| 229 | }
|
|---|
| 230 | return wndold->getWindowHandle();
|
|---|
| 231 | }
|
|---|
| 232 | //******************************************************************************
|
|---|
| 233 | //******************************************************************************
|
|---|