ReactOS 0.4.15-dev-8145-ga541a46
clipboard.c File Reference
#include <user32.h>
Include dependency graph for clipboard.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (user32)
 
HANDLE WINAPI GdiConvertMetaFilePict (HANDLE)
 
HANDLE WINAPI GdiConvertEnhMetaFile (HANDLE)
 
HANDLE WINAPI GdiCreateLocalEnhMetaFile (HANDLE)
 
HANDLE WINAPI GdiCreateLocalMetaFilePict (HANDLE)
 
BOOL WINAPI OpenClipboard (HWND hWndNewOwner)
 
UINT WINAPI EnumClipboardFormats (UINT format)
 
INT WINAPI GetClipboardFormatNameA (UINT format, LPSTR lpszFormatName, int cchMaxCount)
 
INT WINAPI GetClipboardFormatNameW (UINT uFormat, LPWSTR lpszFormatName, INT cchMaxCount)
 
UINT WINAPI RegisterClipboardFormatA (LPCSTR lpszFormat)
 
UINT WINAPI RegisterClipboardFormatW (LPCWSTR lpszFormat)
 
static PVOID WINAPI IntSynthesizeMultiByte (PVOID pwStr, DWORD cbStr, BOOL bOem)
 
static PVOID WINAPI IntSynthesizeWideChar (PVOID pwStr, DWORD cbStr, BOOL bOem)
 
HANDLE WINAPI GetClipboardData (UINT uFormat)
 
HANDLE WINAPI SetClipboardData (UINT uFormat, HANDLE hMem)
 
BOOL WINAPI AddClipboardFormatListener (HWND hwnd)
 
BOOL WINAPI RemoveClipboardFormatListener (HWND hwnd)
 
BOOL WINAPI GetUpdatedClipboardFormats (PUINT lpuiFormats, UINT cFormats, PUINT pcFormatsOut)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file clipboard.c.

Function Documentation

◆ AddClipboardFormatListener()

BOOL WINAPI AddClipboardFormatListener ( HWND  hwnd)

Definition at line 382 of file clipboard.c.

383{
385 return FALSE;
386}
#define UNIMPLEMENTED
Definition: debug.h:118
#define FALSE
Definition: types.h:117

◆ EnumClipboardFormats()

UINT WINAPI EnumClipboardFormats ( UINT  format)

Definition at line 39 of file clipboard.c.

40{
43}
#define NO_ERROR
Definition: dderror.h:5
#define SetLastError(x)
Definition: compat.h:752
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
EXTINLINE UINT NtUserxEnumClipboardFormats(UINT format)
Definition: ntwrapper.h:611

◆ GdiConvertEnhMetaFile()

HANDLE WINAPI GdiConvertEnhMetaFile ( HANDLE  )

Referenced by SetClipboardData().

◆ GdiConvertMetaFilePict()

HANDLE WINAPI GdiConvertMetaFilePict ( HANDLE  hMetaFilePict)

Definition at line 201 of file metafile.c.

202{
203 HMETAFILE hMF;
204 UINT nSize;
205 HANDLE hmo = NULL;
206 BYTE * Buffer = NULL;
207 METAFILEPICT * pInfo = NULL;
208
209 // get METAFILEPICT pointer
210 pInfo = (METAFILEPICT *)GlobalLock(hMetaFilePict);
211 if (pInfo == NULL)
212 goto Exit;
213
214 // get metafile handle
215 hMF = pInfo->hMF;
216
217 // get size of buffer
218 nSize = GetMetaFileBitsEx(hMF, 0, NULL);
219 if (nSize == 0)
220 goto Exit;
221
222 // allocate buffer
224 if (Buffer == NULL)
225 goto Exit;
226
227 // store to buffer
229 if (nSize == 0)
230 goto Exit;
231
232 hmo = NtGdiCreateServerMetaFile( GDITAG_TYPE_MFP, nSize, Buffer, pInfo->mm, pInfo->xExt, pInfo->yExt);
233
234Exit:
235 // clean up
236 if (pInfo)
237 GlobalUnlock(hMetaFilePict);
238 if (Buffer)
240 return hmo; // success if non-NULL
241}
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
unsigned int UINT
Definition: ndis.h:50
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiCreateServerMetaFile(_In_ DWORD iType, _In_ ULONG cjData, _In_reads_bytes_(cjData) LPBYTE pjData, _In_ DWORD mm, _In_ DWORD xExt, _In_ DWORD yExt)
#define GDITAG_TYPE_MFP
Definition: ntgdityp.h:247
static void Exit(void)
Definition: sock.c:1330
HMETAFILE hMF
Definition: wingdi.h:2608
#define LPTR
Definition: winbase.h:381
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2084
UINT WINAPI GetMetaFileBitsEx(_In_ HMETAFILE hMF, _In_ UINT cbBuffer, _Out_writes_bytes_opt_(cbBuffer) LPVOID lpData)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by SetClipboardData().

◆ GdiCreateLocalEnhMetaFile()

HANDLE WINAPI GdiCreateLocalEnhMetaFile ( HANDLE  hmo)

Definition at line 74 of file enhmfile.c.

75{
76 HENHMETAFILE hEMF;
77 BYTE * Buffer = NULL;
78 UINT nSize;
79 DWORD iType, mm, xExt, yExt;
80
82 if (nSize == 0)
83 goto Exit;
84
85 // allocate buffer
87 if (Buffer == NULL)
88 goto Exit;
89
90 // store to buffer
91 nSize = NtGdiGetServerMetaFileBits( hmo, nSize, Buffer, &iType, &mm, &xExt, &yExt);
92 if (nSize == 0)
93 goto Exit;
94
95 if ( iType == GDITAG_TYPE_MFP ) // handle conversion to EMF
96 {
98
99 Info.hMF = NULL;
100 Info.mm = mm;
101 Info.xExt = xExt;
102 Info.yExt = yExt;
103
104 hEMF = SetWinMetaFileBits( nSize, Buffer, NULL, &Info ); // Translate from old style to new style.
105 if (hEMF == NULL)
106 goto Exit;
107 }
108 else
109 {
111 if (hEMF == NULL)
112 goto Exit;
113 }
114
115Exit:
116 // clean up
117 if (Buffer)
119 return hEMF;
120}
unsigned long DWORD
Definition: ntddk_ex.h:95
__kernel_entry W32KAPI ULONG APIENTRY NtGdiGetServerMetaFileBits(_In_ HANDLE hmo, _In_ ULONG cjData, _Out_writes_bytes_opt_(cjData) LPBYTE pjData, _Out_ PDWORD piType, _Out_ PDWORD pmm, _Out_ PDWORD pxExt, _Out_ PDWORD pyExt)
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_In_ ULONG iType
Definition: winddi.h:3748
HENHMETAFILE WINAPI SetEnhMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *pb)
HENHMETAFILE WINAPI SetWinMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *lpMeta16Data, _In_opt_ HDC hdcRef, _In_opt_ const METAFILEPICT *lpMFP)

Referenced by GetClipboardData().

◆ GdiCreateLocalMetaFilePict()

HANDLE WINAPI GdiCreateLocalMetaFilePict ( HANDLE  hmo)

Definition at line 95 of file metafile.c.

96{
97 HGLOBAL hMetaFilePict;
98 METAFILEPICT * pInfo;
99 HMETAFILE hMF = NULL;
100 BYTE * Buffer = NULL;
101 BYTE * BufNew = NULL;
102 HDC hDC = NULL;
103 UINT nSize, cSize;
104 DWORD iType;
105
106 // NOTE: On Win32, there is no difference between the local heap and
107 // the global heap. GlobalAlloc and LocalAlloc have same effect.
108
109 // allocate for METAFILEPICT
110 hMetaFilePict = GlobalAlloc(GHND | GMEM_SHARE, sizeof(METAFILEPICT));
111 pInfo = (METAFILEPICT *)GlobalLock(hMetaFilePict);
112 if (pInfo == NULL)
113 goto Exit;
114
116
117 // allocate buffer
119 if (Buffer == NULL)
120 goto Exit;
121
122 // store to buffer
123 nSize = NtGdiGetServerMetaFileBits( hmo, nSize, Buffer, &iType, (PDWORD)&pInfo->mm, (PDWORD)&pInfo->xExt, (PDWORD)&pInfo->yExt );
124 if (nSize == 0)
125 goto Exit;
126
127 if ( iType == GDITAG_TYPE_EMF ) // handle conversion to MFP
128 {
129 static const WCHAR szDisplayW[] = { 'D','I','S','P','L','A','Y','\0' };
130 HENHMETAFILE hEMF;
131 ENHMETAHEADER emh;
132
134 if (hEMF == NULL)
135 goto Exit;
136
137 if (!GetEnhMetaFileHeader( hEMF, sizeof(emh), &emh ))
138 {
139 DeleteEnhMetaFile(hEMF);
140 goto Exit;
141 }
142
143 pInfo->mm = MM_ANISOTROPIC; // wine uses MM_ISOTROPIC.
144 pInfo->xExt = emh.rclFrame.right - emh.rclFrame.left; // Width
145 pInfo->yExt = emh.rclFrame.bottom - emh.rclFrame.top; // Height
146
147 hDC = CreateDCW(szDisplayW, NULL, NULL, NULL);
148 if (hDC)
149 {
150 cSize = GetWinMetaFileBits( hEMF, 0, NULL, MM_ANISOTROPIC, hDC );
151 if (cSize)
152 {
153 BufNew = (BYTE *)LocalAlloc(LPTR, cSize);
154 if (BufNew)
155 {
156 nSize = GetWinMetaFileBits( hEMF, cSize, (LPBYTE)BufNew, MM_ANISOTROPIC, hDC );
157 if (nSize == cSize)
158 {
159 if (Buffer) LocalFree(Buffer);
160 Buffer = BufNew;
161 }
162 }
163 }
164 DeleteDC(hDC);
165 }
166 DeleteEnhMetaFile(hEMF);
167
168 if (Buffer != BufNew)
169 goto Exit;
170 }
171
172 // create metafile from buffer
174 if (hMF == NULL)
175 goto Exit;
176
177 // set metafile handle
178 pInfo->hMF = hMF;
179
180Exit:
181 // clean up
182 if (Buffer)
184 if (pInfo)
185 GlobalUnlock(hMetaFilePict);
186 if (hMF == NULL)
187 {
188 // failure
189 GlobalFree(hMetaFilePict);
190 hMetaFilePict = NULL;
191 }
192
193 return hMetaFilePict; // success if non-NULL
194}
static HDC hDC
Definition: 3dtext.c:33
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
static HDC
Definition: imagelist.c:92
#define GDITAG_TYPE_EMF
Definition: ntgdityp.h:246
DWORD * PDWORD
Definition: pedump.c:68
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
RECTL rclFrame
Definition: wingdi.h:2323
unsigned char * LPBYTE
Definition: typedefs.h:53
#define GHND
Definition: winbase.h:297
#define GMEM_SHARE
Definition: winbase.h:305
BOOL WINAPI DeleteEnhMetaFile(_In_opt_ HENHMETAFILE)
UINT WINAPI GetWinMetaFileBits(_In_ HENHMETAFILE hemf, _In_ UINT cbData16, _Out_writes_bytes_opt_(cbData16) LPBYTE pData16, _In_ INT iMapMode, _In_ HDC hdcRef)
#define MM_ANISOTROPIC
Definition: wingdi.h:867
HMETAFILE WINAPI SetMetaFileBitsEx(_In_ UINT cbBuffer, _In_reads_bytes_(cbBuffer) CONST BYTE *lpData)
UINT WINAPI GetEnhMetaFileHeader(_In_ HENHMETAFILE hemf, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPENHMETAHEADER lpEnhMetaHeader)
BOOL WINAPI DeleteDC(_In_ HDC)
HDC WINAPI CreateDCW(_In_opt_ LPCWSTR pszDriver, _In_opt_ LPCWSTR pszDevice, _In_opt_ LPCWSTR psz, _In_opt_ const DEVMODEW *pdmInit)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GetClipboardData().

◆ GetClipboardData()

HANDLE WINAPI GetClipboardData ( UINT  uFormat)

Definition at line 198 of file clipboard.c.

199{
200 HANDLE hData = NULL;
201 PVOID pData = NULL;
202 DWORD cbData = 0;
204
205 hData = NtUserGetClipboardData(uFormat, &gcd);
206 if (!hData)
207 return NULL;
208
209 switch (uFormat)
210 {
212 case CF_METAFILEPICT:
213 return GdiCreateLocalMetaFilePict(hData);
215 case CF_ENHMETAFILE:
216 return GdiCreateLocalEnhMetaFile(hData);
217 }
218
219 if (gcd.fGlobalHandle)
220 {
221 HANDLE hGlobal;
222
223 NtUserCreateLocalMemHandle(hData, NULL, 0, &cbData);
224 hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, cbData);
225 pData = GlobalLock(hGlobal);
226 NtUserCreateLocalMemHandle(hData, pData, cbData, NULL);
227 hData = hGlobal;
228 }
229
230 if (gcd.uFmtRet != uFormat)
231 {
232 SETCLIPBDATA scd = {FALSE, FALSE};
233 HANDLE hNewData = NULL;
234 PVOID pNewData = NULL;
235
236 /* Synthesize requested format */
237 switch (uFormat)
238 {
239 case CF_TEXT:
240 if (gcd.uFmtRet == CF_UNICODETEXT)
241 pNewData = IntSynthesizeMultiByte(pData, cbData, uFormat == CF_OEMTEXT);
242 else // CF_OEMTEXT
243 OemToCharBuffA(pData, pData, cbData);
244 break;
245 case CF_OEMTEXT:
246 if (gcd.uFmtRet == CF_UNICODETEXT)
247 pNewData = IntSynthesizeMultiByte(pData, cbData, uFormat == CF_OEMTEXT);
248 else
249 CharToOemBuffA(pData, pData, cbData);
250 break;
251 case CF_UNICODETEXT:
252 pNewData = IntSynthesizeWideChar(pData, cbData, gcd.uFmtRet == CF_OEMTEXT);
253 break;
254 default:
255 FIXME("Format: %u != %u\n", uFormat, gcd.uFmtRet);
256 }
257
258 /* Is it a global handle? */
259 if (pNewData)
260 hNewData = GlobalHandle(pNewData);
261
262 if (hNewData)
263 {
264 /* Free old data */
265 if (pData)
266 {
267 GlobalUnlock(hData);
268 GlobalFree(hData);
269 }
270 hData = hNewData;
271 pData = pNewData;
272 }
273
274 /* Save synthesized format in clipboard */
275 if (pData)
276 {
277 HANDLE hMem;
278
279 scd.fGlobalHandle = TRUE;
281 NtUserSetClipboardData(uFormat, hMem, &scd);
282 }
283 else if (hData)
284 NtUserSetClipboardData(uFormat, hData, &scd);
285 }
286
287 /* Unlock global handle */
288 if (pData)
289 GlobalUnlock(hData);
290
291 return hData;
292}
#define CF_UNICODETEXT
Definition: constants.h:408
#define CF_METAFILEPICT
Definition: constants.h:398
#define CF_DSPENHMETAFILE
Definition: constants.h:417
#define CF_DSPMETAFILEPICT
Definition: constants.h:416
#define CF_ENHMETAFILE
Definition: constants.h:409
#define CF_TEXT
Definition: constants.h:396
#define CF_OEMTEXT
Definition: constants.h:402
#define FIXME(fmt,...)
Definition: debug.h:114
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalHandle(LPCVOID pMem)
Definition: heapmem.c:705
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
HANDLE NTAPI NtUserSetClipboardData(UINT fmt, HANDLE hMem, PSETCLIPBDATA scd)
Definition: clipboard.c:1084
HANDLE NTAPI NtUserConvertMemHandle(PVOID pData, DWORD cbData)
Definition: clipboard.c:1187
HANDLE NTAPI NtUserGetClipboardData(UINT fmt, PGETCLIPBDATA pgcd)
Definition: clipboard.c:897
NTSTATUS NTAPI NtUserCreateLocalMemHandle(HANDLE hMem, PVOID pData, DWORD cbData, DWORD *pcbData)
Definition: clipboard.c:1232
static int gcd(int, int)
Definition: getopt.c:86
BOOL fGlobalHandle
Definition: ntuser.h:1168
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
HANDLE WINAPI GdiCreateLocalMetaFilePict(HANDLE)
Definition: metafile.c:95
static PVOID WINAPI IntSynthesizeWideChar(PVOID pwStr, DWORD cbStr, BOOL bOem)
Definition: clipboard.c:175
HANDLE WINAPI GdiCreateLocalEnhMetaFile(HANDLE)
Definition: enhmfile.c:74
static PVOID WINAPI IntSynthesizeMultiByte(PVOID pwStr, DWORD cbStr, BOOL bOem)
Definition: clipboard.c:154
#define GMEM_MOVEABLE
Definition: winbase.h:294
#define GMEM_DDESHARE
Definition: winbase.h:298
BOOL WINAPI CharToOemBuffA(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPSTR lpszDst, _In_ DWORD cchDstLength)
BOOL WINAPI OemToCharBuffA(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPSTR lpszDst, _In_ DWORD cchDstLength)

◆ GetClipboardFormatNameA()

INT WINAPI GetClipboardFormatNameA ( UINT  format,
LPSTR  lpszFormatName,
int  cchMaxCount 
)

Definition at line 50 of file clipboard.c.

53{
55 INT Length;
56
57 lpBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, cchMaxCount * sizeof(WCHAR));
58 if (!lpBuffer)
59 {
61 return 0;
62 }
63
64 /* we need a UNICODE string */
66
67 if (Length != 0)
68 {
69 if (!WideCharToMultiByte(CP_ACP, 0, lpBuffer, Length, lpszFormatName, cchMaxCount, NULL, NULL))
70 {
71 /* clear result string */
72 Length = 0;
73 }
74 lpszFormatName[Length] = ANSI_NULL;
75 }
76
77 RtlFreeHeap(RtlGetProcessHeap(), 0, lpBuffer);
78 return Length;
79}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
INT NTAPI NtUserGetClipboardFormatName(UINT uFormat, LPWSTR lpszFormatName, INT cchMaxCount)
Definition: clipboard.c:736
#define ANSI_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
int32_t INT
Definition: typedefs.h:58
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ GetClipboardFormatNameW()

INT WINAPI GetClipboardFormatNameW ( UINT  uFormat,
LPWSTR  lpszFormatName,
INT  cchMaxCount 
)

Definition at line 86 of file clipboard.c.

89{
90 return NtUserGetClipboardFormatName(uFormat, lpszFormatName, cchMaxCount);
91}

◆ GetUpdatedClipboardFormats()

BOOL WINAPI GetUpdatedClipboardFormats ( PUINT  lpuiFormats,
UINT  cFormats,
PUINT  pcFormatsOut 
)

Definition at line 403 of file clipboard.c.

406{
408 return FALSE;
409}

◆ IntSynthesizeMultiByte()

static PVOID WINAPI IntSynthesizeMultiByte ( PVOID  pwStr,
DWORD  cbStr,
BOOL  bOem 
)
static

Definition at line 154 of file clipboard.c.

155{
156 HANDLE hGlobal;
157 PVOID pGlobal;
158 INT cbGlobal;
159
160 cbGlobal = WideCharToMultiByte(bOem ? CP_OEMCP : CP_ACP,
161 0, pwStr, cbStr / sizeof(WCHAR),
162 NULL, 0, NULL, NULL);
163 hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, cbGlobal);
164 if (!hGlobal)
165 return NULL;
166
167 pGlobal = GlobalLock(hGlobal);
169 0, pwStr, cbStr / sizeof(WCHAR),
170 pGlobal, cbGlobal, NULL, NULL);
171 return pGlobal;
172}
#define CP_OEMCP
Definition: winnls.h:231

Referenced by GetClipboardData().

◆ IntSynthesizeWideChar()

static PVOID WINAPI IntSynthesizeWideChar ( PVOID  pwStr,
DWORD  cbStr,
BOOL  bOem 
)
static

Definition at line 175 of file clipboard.c.

176{
177 HANDLE hGlobal;
178 PVOID pGlobal;
179 INT cbGlobal;
180
181 cbGlobal = MultiByteToWideChar(bOem ? CP_OEMCP : CP_ACP,
182 0, pwStr, cbStr, NULL, 0) * sizeof(WCHAR);
183 hGlobal = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, cbGlobal);
184 if (!hGlobal)
185 return NULL;
186
187 pGlobal = GlobalLock(hGlobal);
189 0, pwStr, cbStr, pGlobal, cbGlobal);
190 return pGlobal;
191}
#define MultiByteToWideChar
Definition: compat.h:110

Referenced by GetClipboardData().

◆ OpenClipboard()

BOOL WINAPI OpenClipboard ( HWND  hWndNewOwner)

Definition at line 29 of file clipboard.c.

30{
31 return NtUserOpenClipboard(hWndNewOwner, 0);
32}
BOOL NTAPI NtUserOpenClipboard(HWND hWnd, DWORD Unknown1)
Definition: clipboard.c:533

◆ RegisterClipboardFormatA()

UINT WINAPI RegisterClipboardFormatA ( LPCSTR  lpszFormat)

Definition at line 98 of file clipboard.c.

99{
100 UINT ret;
101 UNICODE_STRING usFormat = {0};
102
103 if (lpszFormat == NULL)
104 {
106 return 0;
107 }
108
109 if (*lpszFormat == ANSI_NULL)
110 {
112 return 0;
113 }
114
115 if (!RtlCreateUnicodeStringFromAsciiz(&usFormat, lpszFormat))
116 {
118 return 0;
119 }
120
121 ret = NtUserRegisterWindowMessage(&usFormat); //(LPCWSTR)
122
123 RtlFreeUnicodeString(&usFormat);
124
125 return ret;
126}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_INVALID_NAME
Definition: compat.h:103
UINT NTAPI NtUserRegisterWindowMessage(PUNICODE_STRING MessageName)
Definition: window.c:4294
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
int ret

◆ RegisterClipboardFormatW()

UINT WINAPI RegisterClipboardFormatW ( LPCWSTR  lpszFormat)

Definition at line 133 of file clipboard.c.

134{
135 UNICODE_STRING usFormat = {0};
136
137 if (lpszFormat == NULL)
138 {
140 return 0;
141 }
142
143 if (*lpszFormat == UNICODE_NULL)
144 {
146 return 0;
147 }
148
149 RtlInitUnicodeString(&usFormat, lpszFormat);
150 return NtUserRegisterWindowMessage(&usFormat);
151}
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNICODE_NULL

◆ RemoveClipboardFormatListener()

BOOL WINAPI RemoveClipboardFormatListener ( HWND  hwnd)

Definition at line 392 of file clipboard.c.

393{
395 return FALSE;
396}

◆ SetClipboardData()

HANDLE WINAPI SetClipboardData ( UINT  uFormat,
HANDLE  hMem 
)

Definition at line 299 of file clipboard.c.

300{
302 HANDLE hGlobal;
303 LPVOID pMem;
304 HANDLE hRet = NULL, hTemp;
305 SETCLIPBDATA scd = {FALSE, FALSE};
306
307 /* Check if this is a delayed rendering */
308 if (hMem == NULL)
309 return NtUserSetClipboardData(uFormat, NULL, &scd);
310
311 if (hMem <= (HANDLE)4)
313 /* Bitmaps and palette does not use global handles */
314 else if (uFormat == CF_BITMAP || uFormat == CF_DSPBITMAP || uFormat == CF_PALETTE)
315 hRet = NtUserSetClipboardData(uFormat, hMem, &scd);
316 /* Meta files are probably checked for validity */
317 else if (uFormat == CF_DSPMETAFILEPICT || uFormat == CF_METAFILEPICT )
318 {
319 hTemp = GdiConvertMetaFilePict( hMem );
320 hRet = NtUserSetClipboardData(uFormat, hTemp, &scd); // Note : LOL, it returns a BOOL not a HANDLE!!!!
321 if (hRet == hTemp) hRet = hMem; // If successful "TRUE", return the original handle.
322 }
323 else if (uFormat == CF_DSPENHMETAFILE || uFormat == CF_ENHMETAFILE)
324 {
325 hTemp = GdiConvertEnhMetaFile( hMem );
326 hRet = NtUserSetClipboardData(uFormat, hTemp, &scd);
327 if (hRet == hTemp) hRet = hMem;
328 }
329 else
330 {
331 /* Some formats accept only global handles, other accept global handles or integer values */
332 pMem = GlobalLock(hMem);
333 dwSize = GlobalSize(hMem);
334
335 if (pMem || uFormat == CF_DIB || uFormat == CF_DIBV5 ||
336 uFormat == CF_DSPTEXT || uFormat == CF_LOCALE ||
337 uFormat == CF_OEMTEXT || uFormat == CF_TEXT ||
338 uFormat == CF_UNICODETEXT)
339 {
340 if (pMem)
341 {
342 /* This is a local memory. Make global memory object */
343 hGlobal = NtUserConvertMemHandle(pMem, dwSize);
344
345 /* Unlock memory */
346 GlobalUnlock(hMem);
347 /* FIXME: free hMem when CloseClipboard is called */
348
349 if (hGlobal)
350 {
351 /* Save data */
352 scd.fGlobalHandle = TRUE;
353 hRet = NtUserSetClipboardData(uFormat, hGlobal, &scd);
354 }
355
356 /* On success NtUserSetClipboardData returns pMem
357 however caller expects us to return hMem */
358 if (hRet == hGlobal)
359 hRet = hMem;
360 }
361 else
363 }
364 else
365 {
366 /* Save a number */
367 hRet = NtUserSetClipboardData(uFormat, hMem, &scd);
368 }
369 }
370
371 if (!hRet)
372 ERR("SetClipboardData(%u, %p) failed\n", uFormat, hMem);
373
374 return hRet;
375}
#define CF_BITMAP
Definition: constants.h:397
#define CF_PALETTE
Definition: constants.h:404
#define CF_LOCALE
Definition: constants.h:411
#define CF_DSPBITMAP
Definition: constants.h:415
#define CF_DSPTEXT
Definition: constants.h:414
#define CF_DIB
Definition: constants.h:403
#define ERR(fmt,...)
Definition: debug.h:113
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
HANDLE WINAPI GdiConvertMetaFilePict(HANDLE)
Definition: metafile.c:201
HANDLE WINAPI GdiConvertEnhMetaFile(HANDLE)

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( user32  )