3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
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.
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.
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.
20 * PROJECT: ReactOS user32.dll
21 * FILE: lib/user32/windows/input.c
23 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
25 * 09-05-2001 CSH Created
28 /* INCLUDES ******************************************************************/
32 #include <wine/debug.h>
34 WINE_DEFAULT_DEBUG_CHANNEL(user32
);
36 #define ATOM_BUFFER_SIZE 256
38 /* INTERNAL FUNCTIONS ********************************************************/
42 IntGetProp(HWND hWnd
, ATOM Atom
)
44 PLIST_ENTRY ListEntry
, temp
;
49 pWnd
= ValidateHwnd(hWnd
);
50 if (!pWnd
) return NULL
;
52 ListEntry
= SharedPtrToUser(pWnd
->PropListHead
.Flink
);
53 for (i
= 0; i
< pWnd
->PropListItems
; i
++ )
55 Property
= CONTAINING_RECORD(ListEntry
, PROPERTY
, PropListEntry
);
56 if (Property
->Atom
== Atom
)
60 temp
= ListEntry
->Flink
;
61 ListEntry
= SharedPtrToUser(temp
);
67 /* FUNCTIONS *****************************************************************/
73 EnumPropsA(HWND hWnd
, PROPENUMPROCA lpEnumFunc
)
82 SetLastError(ERROR_INVALID_PARAMETER
);
86 Status
= NtUserBuildPropList(hWnd
, NULL
, 0, &Count
);
87 if(!NT_SUCCESS(Status
))
89 if(Status
== STATUS_INVALID_HANDLE
)
90 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
92 SetLastError(RtlNtStatusToDosError(Status
));
98 pli
= RtlAllocateHeap(GetProcessHeap(), 0, Count
);
101 SetLastError(ERROR_OUTOFMEMORY
);
105 Status
= NtUserBuildPropList(hWnd
, (LPVOID
)pli
, Count
, &Count
);
106 if(!NT_SUCCESS(Status
))
108 RtlFreeHeap(GetProcessHeap(), 0, pli
);
109 if(Status
== STATUS_INVALID_HANDLE
)
110 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
112 SetLastError(RtlNtStatusToDosError(Status
));
117 for(; Count
> 0; Count
--, i
++)
119 char str
[ATOM_BUFFER_SIZE
];
121 if(!GlobalGetAtomNameA(i
->Atom
, str
, ATOM_BUFFER_SIZE
))
124 ret
= lpEnumFunc(hWnd
, str
, i
->Data
);
129 RtlFreeHeap(GetProcessHeap(), 0, pli
);
140 EnumPropsExA(HWND hWnd
, PROPENUMPROCEXA lpEnumFunc
, LPARAM lParam
)
142 PPROPLISTITEM pli
, i
;
149 SetLastError(ERROR_INVALID_PARAMETER
);
153 Status
= NtUserBuildPropList(hWnd
, NULL
, 0, &Count
);
154 if(!NT_SUCCESS(Status
))
156 if(Status
== STATUS_INVALID_HANDLE
)
157 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
159 SetLastError(RtlNtStatusToDosError(Status
));
165 pli
= RtlAllocateHeap(GetProcessHeap(), 0, Count
);
168 SetLastError(ERROR_OUTOFMEMORY
);
172 Status
= NtUserBuildPropList(hWnd
, (LPVOID
)pli
, Count
, &Count
);
173 if(!NT_SUCCESS(Status
))
175 RtlFreeHeap(GetProcessHeap(), 0, pli
);
176 if(Status
== STATUS_INVALID_HANDLE
)
177 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
179 SetLastError(RtlNtStatusToDosError(Status
));
184 for(; Count
> 0; Count
--, i
++)
186 char str
[ATOM_BUFFER_SIZE
];
188 if(!GlobalGetAtomNameA(i
->Atom
, str
, ATOM_BUFFER_SIZE
))
191 ret
= lpEnumFunc(hWnd
, str
, i
->Data
, lParam
);
196 RtlFreeHeap(GetProcessHeap(), 0, pli
);
207 EnumPropsExW(HWND hWnd
, PROPENUMPROCEXW lpEnumFunc
, LPARAM lParam
)
209 PPROPLISTITEM pli
, i
;
216 SetLastError(ERROR_INVALID_PARAMETER
);
220 Status
= NtUserBuildPropList(hWnd
, NULL
, 0, &Count
);
221 if(!NT_SUCCESS(Status
))
223 if(Status
== STATUS_INVALID_HANDLE
)
224 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
226 SetLastError(RtlNtStatusToDosError(Status
));
232 pli
= RtlAllocateHeap(GetProcessHeap(), 0, Count
);
235 SetLastError(ERROR_OUTOFMEMORY
);
239 Status
= NtUserBuildPropList(hWnd
, (LPVOID
)pli
, Count
, &Count
);
240 if(!NT_SUCCESS(Status
))
242 RtlFreeHeap(GetProcessHeap(), 0, pli
);
243 if(Status
== STATUS_INVALID_HANDLE
)
244 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
246 SetLastError(RtlNtStatusToDosError(Status
));
251 for(; Count
> 0; Count
--, i
++)
253 WCHAR str
[ATOM_BUFFER_SIZE
];
255 if(!GlobalGetAtomNameW(i
->Atom
, str
, ATOM_BUFFER_SIZE
))
258 ret
= lpEnumFunc(hWnd
, str
, i
->Data
, lParam
);
263 RtlFreeHeap(GetProcessHeap(), 0, pli
);
274 EnumPropsW(HWND hWnd
, PROPENUMPROCW lpEnumFunc
)
276 PPROPLISTITEM pli
, i
;
283 SetLastError(ERROR_INVALID_PARAMETER
);
287 Status
= NtUserBuildPropList(hWnd
, NULL
, 0, &Count
);
288 if(!NT_SUCCESS(Status
))
290 if(Status
== STATUS_INVALID_HANDLE
)
291 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
293 SetLastError(RtlNtStatusToDosError(Status
));
299 pli
= RtlAllocateHeap(GetProcessHeap(), 0, Count
);
302 SetLastError(ERROR_OUTOFMEMORY
);
306 Status
= NtUserBuildPropList(hWnd
, (LPVOID
)pli
, Count
, &Count
);
307 if(!NT_SUCCESS(Status
))
309 RtlFreeHeap(GetProcessHeap(), 0, pli
);
310 if(Status
== STATUS_INVALID_HANDLE
)
311 SetLastError(ERROR_INVALID_WINDOW_HANDLE
);
313 SetLastError(RtlNtStatusToDosError(Status
));
318 for(; Count
> 0; Count
--, i
++)
320 WCHAR str
[ATOM_BUFFER_SIZE
];
322 if(!GlobalGetAtomNameW(i
->Atom
, str
, ATOM_BUFFER_SIZE
))
325 ret
= lpEnumFunc(hWnd
, str
, i
->Data
);
330 RtlFreeHeap(GetProcessHeap(), 0, pli
);
341 GetPropA(HWND hWnd
, LPCSTR lpString
)
344 UNICODE_STRING UString
;
346 if (HIWORD(lpString
))
348 RtlCreateUnicodeStringFromAsciiz(&UString
, (LPSTR
)lpString
);
349 lpWString
= UString
.Buffer
;
350 if (lpWString
== NULL
)
354 Ret
= GetPropW(hWnd
, lpWString
);
355 RtlFreeUnicodeString(&UString
);
359 Ret
= GetPropW(hWnd
, (LPWSTR
)lpString
);
369 GetPropW(HWND hWnd
, LPCWSTR lpString
)
374 if (HIWORD(lpString
))
376 Atom
= GlobalFindAtomW(lpString
);
380 Atom
= LOWORD((DWORD_PTR
)lpString
);
382 Prop
= IntGetProp(hWnd
, Atom
);
383 if (Prop
!= NULL
) Data
= Prop
->Data
;
392 RemovePropA(HWND hWnd
, LPCSTR lpString
)
395 UNICODE_STRING UString
;
398 if (HIWORD(lpString
))
400 RtlCreateUnicodeStringFromAsciiz(&UString
, (LPSTR
)lpString
);
401 lpWString
= UString
.Buffer
;
402 if (lpWString
== NULL
)
406 Ret
= RemovePropW(hWnd
, lpWString
);
407 RtlFreeUnicodeString(&UString
);
411 Ret
= RemovePropW(hWnd
, (LPCWSTR
)lpString
);
421 RemovePropW(HWND hWnd
,
425 if (HIWORD(lpString
))
427 Atom
= GlobalFindAtomW(lpString
);
431 Atom
= LOWORD((DWORD_PTR
)lpString
);
433 return(NtUserRemoveProp(hWnd
, Atom
));
441 SetPropA(HWND hWnd
, LPCSTR lpString
, HANDLE hData
)
444 UNICODE_STRING UString
;
447 if (HIWORD(lpString
))
449 RtlCreateUnicodeStringFromAsciiz(&UString
, (LPSTR
)lpString
);
450 lpWString
= UString
.Buffer
;
451 if (lpWString
== NULL
)
455 Ret
= SetPropW(hWnd
, lpWString
, hData
);
456 RtlFreeUnicodeString(&UString
);
460 Ret
= SetPropW(hWnd
, (LPWSTR
)lpString
, hData
);
470 SetPropW(HWND hWnd
, LPCWSTR lpString
, HANDLE hData
)
473 if (HIWORD(lpString
))
475 Atom
= GlobalAddAtomW(lpString
);
479 Atom
= LOWORD((DWORD_PTR
)lpString
);
482 return(NtUserSetProp(hWnd
, Atom
, hData
));