2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * PURPOSE: Window properties
23 * FILE: subsys/win32k/ntuser/prop.c
24 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
26 * 06-06-2001 CSH Created
28 /* INCLUDES ******************************************************************/
35 /* STATIC FUNCTIONS **********************************************************/
38 IntGetProp(PWINDOW_OBJECT Window
, ATOM Atom
)
40 PLIST_ENTRY ListEntry
;
43 ListEntry
= Window
->Wnd
->PropListHead
.Flink
;
44 while (ListEntry
!= &Window
->Wnd
->PropListHead
)
46 Property
= CONTAINING_RECORD(ListEntry
, PROPERTY
, PropListEntry
);
47 if (Property
->Atom
== Atom
)
51 ListEntry
= ListEntry
->Flink
;
57 IntRemoveProp(PWINDOW_OBJECT Window
, ATOM Atom
)
61 Prop
= IntGetProp(Window
, Atom
);
68 RemoveEntryList(&Prop
->PropListEntry
);
70 Window
->Wnd
->PropListItems
--;
75 IntSetProp(PWINDOW_OBJECT pWnd
, ATOM Atom
, HANDLE Data
)
79 Prop
= IntGetProp(pWnd
, Atom
);
83 Prop
= UserHeapAlloc(sizeof(PROPERTY
));
89 InsertTailList(&pWnd
->Wnd
->PropListHead
, &Prop
->PropListEntry
);
90 pWnd
->Wnd
->PropListItems
++;
97 /* FUNCTIONS *****************************************************************/
100 NtUserBuildPropList(HWND hWnd
,
105 PWINDOW_OBJECT Window
;
107 PLIST_ENTRY ListEntry
;
108 PROPLISTITEM listitem
, *li
;
111 DECLARE_RETURN(NTSTATUS
);
113 DPRINT("Enter NtUserBuildPropList\n");
116 if (!(Window
= UserGetWindowObject(hWnd
)))
118 RETURN( STATUS_INVALID_HANDLE
);
123 if(!BufferSize
|| (BufferSize
% sizeof(PROPLISTITEM
) != 0))
125 RETURN( STATUS_INVALID_PARAMETER
);
129 li
= (PROPLISTITEM
*)Buffer
;
130 ListEntry
= Window
->Wnd
->PropListHead
.Flink
;
131 while((BufferSize
>= sizeof(PROPLISTITEM
)) && (ListEntry
!= &Window
->Wnd
->PropListHead
))
133 Property
= CONTAINING_RECORD(ListEntry
, PROPERTY
, PropListEntry
);
134 listitem
.Atom
= Property
->Atom
;
135 listitem
.Data
= Property
->Data
;
137 Status
= MmCopyToCaller(li
, &listitem
, sizeof(PROPLISTITEM
));
138 if(!NT_SUCCESS(Status
))
143 BufferSize
-= sizeof(PROPLISTITEM
);
146 ListEntry
= ListEntry
->Flink
;
152 Cnt
= Window
->Wnd
->PropListItems
* sizeof(PROPLISTITEM
);
157 Status
= MmCopyToCaller(Count
, &Cnt
, sizeof(DWORD
));
158 if(!NT_SUCCESS(Status
))
164 RETURN( STATUS_SUCCESS
);
167 DPRINT("Leave NtUserBuildPropList, ret=%i\n",_ret_
);
173 NtUserRemoveProp(HWND hWnd
, ATOM Atom
)
175 PWINDOW_OBJECT Window
;
178 DECLARE_RETURN(HANDLE
);
180 DPRINT("Enter NtUserRemoveProp\n");
181 UserEnterExclusive();
183 if (!(Window
= UserGetWindowObject(hWnd
)))
188 Prop
= IntGetProp(Window
, Atom
);
195 RemoveEntryList(&Prop
->PropListEntry
);
197 Window
->Wnd
->PropListItems
--;
202 DPRINT("Leave NtUserRemoveProp, ret=%i\n",_ret_
);
208 NtUserSetProp(HWND hWnd
, ATOM Atom
, HANDLE Data
)
210 PWINDOW_OBJECT Window
;
211 DECLARE_RETURN(BOOL
);
213 DPRINT("Enter NtUserSetProp\n");
214 UserEnterExclusive();
216 if (!(Window
= UserGetWindowObject(hWnd
)))
221 RETURN( IntSetProp(Window
, Atom
, Data
));
224 DPRINT("Leave NtUserSetProp, ret=%i\n",_ret_
);