ReactOS 0.4.15-dev-8236-g99f0937
prop.c
Go to the documentation of this file.
1/*
2 * ReactOS kernel
3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19/*
20 * PROJECT: ReactOS user32.dll
21 * FILE: win32ss/user/user32/windows/prop.c
22 * PURPOSE: Window Property
23 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
24 * UPDATE HISTORY:
25 * 09-05-2001 CSH Created
26 */
27
28/* INCLUDES ******************************************************************/
29
30#include <user32.h>
31
32#define ATOM_BUFFER_SIZE 256
33
34/* INTERNAL FUNCTIONS ********************************************************/
35
39{
40 PLIST_ENTRY ListEntry, temp;
42 PWND pWnd;
43 int i;
44 WORD SystemFlag = SystemProp ? PROPERTY_FLAG_SYSTEM : 0;
45
46 pWnd = ValidateHwnd(hWnd);
47 if (!pWnd) return NULL;
48
49 ListEntry = SharedPtrToUser(pWnd->PropListHead.Flink);
50 for (i = 0; i < pWnd->PropListItems; i++ )
51 {
52 Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
53 if (Property->Atom == Atom &&
54 (Property->fs & PROPERTY_FLAG_SYSTEM) == SystemFlag)
55 {
56 return(Property);
57 }
58 temp = ListEntry->Flink;
59 ListEntry = SharedPtrToUser(temp);
60 }
61 return NULL;
62}
63
67{
68 PPROPERTY Prop;
70 return Prop ? Prop->Data : NULL;
71}
72
73/* FUNCTIONS *****************************************************************/
74
75/*
76 * @implemented
77 */
78int WINAPI
80{
81 PPROPLISTITEM pli, i;
84 int ret = -1;
85
86 if(!lpEnumFunc)
87 {
89 return ret;
90 }
91
93 if(!NT_SUCCESS(Status))
94 {
97 else
99 return ret;
100 }
101
102 if(Count > 0)
103 {
105 if (pli == NULL)
106 {
108 return -1;
109 }
110
112 if(!NT_SUCCESS(Status))
113 {
114 RtlFreeHeap(GetProcessHeap(), 0, pli);
117 else
119 return ret;
120 }
121
122 i = pli;
123 for(; Count > 0; Count--, i++)
124 {
125 char str[ATOM_BUFFER_SIZE];
126
128 continue;
129
130 ret = lpEnumFunc(hWnd, str, i->Data);
131 if(!ret)
132 break;
133 }
134
135 RtlFreeHeap(GetProcessHeap(), 0, pli);
136 }
137
138 return ret;
139}
140
141
142/*
143 * @implemented
144 */
145int WINAPI
147{
148 PPROPLISTITEM pli, i;
150 DWORD Count;
151 int ret = -1;
152
153 if(!lpEnumFunc)
154 {
156 return ret;
157 }
158
160 if(!NT_SUCCESS(Status))
161 {
164 else
166 return ret;
167 }
168
169 if(Count > 0)
170 {
172 if (pli == NULL)
173 {
175 return -1;
176 }
177
179 if(!NT_SUCCESS(Status))
180 {
181 RtlFreeHeap(GetProcessHeap(), 0, pli);
184 else
186 return ret;
187 }
188
189 i = pli;
190 for(; Count > 0; Count--, i++)
191 {
192 char str[ATOM_BUFFER_SIZE];
193
195 continue;
196
197 ret = lpEnumFunc(hWnd, str, i->Data, lParam);
198 if(!ret)
199 break;
200 }
201
202 RtlFreeHeap(GetProcessHeap(), 0, pli);
203 }
204
205 return ret;
206}
207
208
209/*
210 * @implemented
211 */
212int WINAPI
214{
215 PPROPLISTITEM pli, i;
217 DWORD Count;
218 int ret = -1;
219
220 if(!lpEnumFunc)
221 {
223 return ret;
224 }
225
227 if(!NT_SUCCESS(Status))
228 {
231 else
233 return ret;
234 }
235
236 if(Count > 0)
237 {
239 if (pli == NULL)
240 {
242 return -1;
243 }
244
246 if(!NT_SUCCESS(Status))
247 {
248 RtlFreeHeap(GetProcessHeap(), 0, pli);
251 else
253 return ret;
254 }
255
256 i = pli;
257 for(; Count > 0; Count--, i++)
258 {
260
262 continue;
263
264 ret = lpEnumFunc(hWnd, str, i->Data, lParam);
265 if(!ret)
266 break;
267 }
268
269 RtlFreeHeap(GetProcessHeap(), 0, pli);
270 }
271
272 return ret;
273}
274
275
276/*
277 * @implemented
278 */
279int WINAPI
281{
282 PPROPLISTITEM pli, i;
284 DWORD Count;
285 int ret = -1;
286
287 if(!lpEnumFunc)
288 {
290 return ret;
291 }
292
294 if(!NT_SUCCESS(Status))
295 {
298 else
300 return ret;
301 }
302
303 if(Count > 0)
304 {
306 if (pli == NULL)
307 {
309 return -1;
310 }
311
313 if(!NT_SUCCESS(Status))
314 {
315 RtlFreeHeap(GetProcessHeap(), 0, pli);
318 else
320 return ret;
321 }
322
323 i = pli;
324 for(; Count > 0; Count--, i++)
325 {
327
329 continue;
330
331 ret = lpEnumFunc(hWnd, str, i->Data);
332 if(!ret)
333 break;
334 }
335
336 RtlFreeHeap(GetProcessHeap(), 0, pli);
337 }
338
339 return ret;
340}
341
342
343/*
344 * @implemented
345 */
348{
349 PWSTR lpWString;
350 UNICODE_STRING UString;
351 HANDLE Ret;
352 if (HIWORD(lpString))
353 {
354 RtlCreateUnicodeStringFromAsciiz(&UString, (LPSTR)lpString);
355 lpWString = UString.Buffer;
356 if (lpWString == NULL)
357 {
358 return(FALSE);
359 }
360 Ret = GetPropW(hWnd, lpWString);
361 RtlFreeUnicodeString(&UString);
362 }
363 else
364 {
365 Ret = GetPropW(hWnd, (LPWSTR)lpString);
366 }
367 return(Ret);
368}
369
370
371/*
372 * @implemented
373 */
376{
377 ATOM Atom;
378 HANDLE Data = NULL;
379 PPROPERTY Prop;
380 if (HIWORD(lpString))
381 {
382 Atom = GlobalFindAtomW(lpString);
383 }
384 else
385 {
386 Atom = LOWORD((DWORD_PTR)lpString);
387 }
388 Prop = IntGetProp(hWnd, Atom, FALSE);
389 if (Prop != NULL) Data = Prop->Data;
390 return Data;
391}
392
393
394/*
395 * @implemented
396 */
399{
400 PWSTR lpWString;
401 UNICODE_STRING UString;
402 HANDLE Ret;
403
404 if (HIWORD(lpString))
405 {
406 RtlCreateUnicodeStringFromAsciiz(&UString, (LPSTR)lpString);
407 lpWString = UString.Buffer;
408 if (lpWString == NULL)
409 {
410 return(FALSE);
411 }
412 Ret = RemovePropW(hWnd, lpWString);
413 RtlFreeUnicodeString(&UString);
414 }
415 else
416 {
417 Ret = RemovePropW(hWnd, (LPCWSTR)lpString);
418 }
419 return(Ret);
420}
421
422
423/*
424 * @implemented
425 */
428 LPCWSTR lpString)
429{
430 ATOM Atom;
431 if (HIWORD(lpString))
432 {
433 Atom = GlobalFindAtomW(lpString);
434 }
435 else
436 {
437 Atom = LOWORD((DWORD_PTR)lpString);
438 }
439 return(NtUserRemoveProp(hWnd, Atom));
440}
441
442
443/*
444 * @implemented
445 */
447SetPropA(HWND hWnd, LPCSTR lpString, HANDLE hData)
448{
449 PWSTR lpWString;
450 UNICODE_STRING UString;
451 BOOL Ret;
452
453 if (HIWORD(lpString))
454 {
455 RtlCreateUnicodeStringFromAsciiz(&UString, (LPSTR)lpString);
456 lpWString = UString.Buffer;
457 if (lpWString == NULL)
458 {
459 return(FALSE);
460 }
461 Ret = SetPropW(hWnd, lpWString, hData);
462 RtlFreeUnicodeString(&UString);
463 }
464 else
465 {
466 Ret = SetPropW(hWnd, (LPWSTR)lpString, hData);
467 }
468 return(Ret);
469}
470
471
472/*
473 * @implemented
474 */
476SetPropW(HWND hWnd, LPCWSTR lpString, HANDLE hData)
477{
478 ATOM Atom;
479 if (HIWORD(lpString))
480 {
481 Atom = GlobalAddAtomW(lpString);
482 }
483 else
484 {
485 Atom = LOWORD((DWORD_PTR)lpString);
486 }
487
488 return(NtUserSetProp(hWnd, Atom, hData));
489}
unsigned char BOOLEAN
HWND hWnd
Definition: settings.c:17
LONG NTSTATUS
Definition: precomp.h:26
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
_Out_ RTL_ATOM * Atom
Definition: class.h:54
LPARAM lParam
Definition: combotst.c:139
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define ValidateHwnd(hwnd)
Definition: precomp.h:85
ATOM WINAPI GlobalFindAtomW(LPCWSTR lpString)
Definition: atom.c:474
UINT WINAPI GlobalGetAtomNameW(ATOM nAtom, LPWSTR lpBuffer, int nSize)
Definition: atom.c:496
UINT WINAPI GlobalGetAtomNameA(ATOM nAtom, LPSTR lpBuffer, int nSize)
Definition: atom.c:484
ATOM WINAPI GlobalAddAtomW(LPCWSTR lpString)
Definition: atom.c:444
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PROPERTY_FLAG_SYSTEM
Definition: ntuser.h:1096
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
int Count
Definition: noreturn.cpp:7
#define FASTCALL
Definition: nt_native.h:50
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
#define LOWORD(l)
Definition: pedump.c:82
_In_ ATOM _In_ HANDLE _In_ BOOLEAN SystemProp
Definition: prop.h:24
const WCHAR * str
static calc_node_t temp
Definition: rpn_ieee.c:38
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
HANDLE Data
Definition: ntuser.h:1101
Definition: ntuser.h:694
ULONG PropListItems
Definition: ntuser.h:724
LIST_ENTRY PropListHead
Definition: ntuser.h:723
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define HIWORD(l)
Definition: typedefs.h:247
static __inline PVOID SharedPtrToUser(PVOID Ptr)
Definition: user_x.h:4
int ret
HANDLE APIENTRY NtUserRemoveProp(_In_ HWND hWnd, _In_ ATOM Atom)
Definition: prop.c:220
PPROPERTY FASTCALL IntGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:16
BOOL APIENTRY NtUserSetProp(_In_ HWND hWnd, _In_ ATOM Atom, _In_ HANDLE Data)
Definition: prop.c:247
NTSTATUS APIENTRY NtUserBuildPropList(_In_ HWND hWnd, _Out_writes_bytes_to_opt_(BufferSize, *Count *sizeof(PROPLISTITEM)) LPVOID Buffer, _In_ DWORD BufferSize, _Out_opt_ DWORD *Count)
Definition: prop.c:137
HANDLE FASTCALL UserGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:46
int WINAPI EnumPropsExW(HWND hWnd, PROPENUMPROCEXW lpEnumFunc, LPARAM lParam)
Definition: prop.c:213
int WINAPI EnumPropsA(HWND hWnd, PROPENUMPROCA lpEnumFunc)
Definition: prop.c:79
HANDLE WINAPI GetPropW(HWND hWnd, LPCWSTR lpString)
Definition: prop.c:375
HANDLE WINAPI RemovePropW(HWND hWnd, LPCWSTR lpString)
Definition: prop.c:427
#define ATOM_BUFFER_SIZE
Definition: prop.c:32
BOOL WINAPI SetPropA(HWND hWnd, LPCSTR lpString, HANDLE hData)
Definition: prop.c:447
HANDLE WINAPI RemovePropA(HWND hWnd, LPCSTR lpString)
Definition: prop.c:398
HANDLE WINAPI GetPropA(HWND hWnd, LPCSTR lpString)
Definition: prop.c:347
int WINAPI EnumPropsExA(HWND hWnd, PROPENUMPROCEXA lpEnumFunc, LPARAM lParam)
Definition: prop.c:146
int WINAPI EnumPropsW(HWND hWnd, PROPENUMPROCW lpEnumFunc)
Definition: prop.c:280
BOOL WINAPI SetPropW(HWND hWnd, LPCWSTR lpString, HANDLE hData)
Definition: prop.c:476
LONG_PTR LPARAM
Definition: windef.h:208
#define WINAPI
Definition: msvc.h:6
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
BOOL(CALLBACK * PROPENUMPROCEXW)(HWND, LPWSTR, HANDLE, ULONG_PTR)
Definition: winuser.h:2903
BOOL(CALLBACK * PROPENUMPROCA)(HWND, LPCSTR, HANDLE)
Definition: winuser.h:2900
BOOL(CALLBACK * PROPENUMPROCEXA)(HWND, LPSTR, HANDLE, ULONG_PTR)
Definition: winuser.h:2902
BOOL(CALLBACK * PROPENUMPROCW)(HWND, LPCWSTR, HANDLE)
Definition: winuser.h:2901
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185