:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / subsys / win32k / ntuser / prop.c
1 /* $Id$
2  *
3  * COPYRIGHT:        See COPYING in the top level directory
4  * PROJECT:          ReactOS kernel
5  * PURPOSE:          Window properties
6  * FILE:             subsys/win32k/ntuser/prop.c
7  * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
8  * REVISION HISTORY:
9  *       06-06-2001  CSH  Created
10  */
11 /* INCLUDES ******************************************************************/
12
13 #include <ddk/ntddk.h>
14 #include <win32k/win32k.h>
15 #include <include/object.h>
16 #include <include/guicheck.h>
17 #include <include/window.h>
18 #include <include/class.h>
19 #include <include/error.h>
20 #include <include/winsta.h>
21 #include <include/winpos.h>
22 #include <include/callback.h>
23 #include <include/msgqueue.h>
24 #include <include/rect.h>
25
26 //#define NDEBUG
27 #include <debug.h>
28
29 /* FUNCTIONS *****************************************************************/
30
31 PPROPERTY
32 W32kGetProp(PWINDOW_OBJECT WindowObject, ATOM Atom)
33 {
34   PLIST_ENTRY ListEntry;
35   PPROPERTY Property;
36   
37   ListEntry = WindowObject->PropListHead.Flink;
38   while (ListEntry != &WindowObject->PropListHead)
39     {
40       Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
41       if (Property->Atom == Atom)
42         {
43           return(Property);
44         }
45       ListEntry = ListEntry->Flink;
46     }
47   return(NULL);
48 }
49
50 DWORD STDCALL
51 NtUserBuildPropList(DWORD Unknown0,
52                     DWORD Unknown1,
53                     DWORD Unknown2,
54                     DWORD Unknown3)
55 {
56   UNIMPLEMENTED
57
58   return 0;
59 }
60
61 HANDLE STDCALL
62 NtUserRemoveProp(HWND hWnd, ATOM Atom)
63 {
64   PWINDOW_OBJECT WindowObject;
65   PPROPERTY Prop;
66   HANDLE Data;
67
68   WindowObject = W32kGetWindowObject(hWnd);
69   if (WindowObject == NULL)
70     {
71       return(NULL);
72     }
73
74   Prop = W32kGetProp(WindowObject, Atom);
75   if (Prop == NULL)
76     {
77       W32kReleaseWindowObject(WindowObject);
78       return(NULL);
79     }
80   Data = Prop->Data;
81   RemoveEntryList(&Prop->PropListEntry);
82   ExFreePool(Prop);
83   W32kReleaseWindowObject(WindowObject);
84   return(Data);
85 }
86
87 HANDLE STDCALL
88 NtUserGetProp(HWND hWnd, ATOM Atom)
89 {
90   PWINDOW_OBJECT WindowObject;
91   PPROPERTY Prop;
92   HANDLE Data = NULL;
93
94   WindowObject = W32kGetWindowObject(hWnd);
95   if (WindowObject == NULL)
96     {
97       return(FALSE);
98     }
99
100   Prop = W32kGetProp(WindowObject, Atom);
101   if (Prop != NULL)
102     {
103       Data = Prop->Data;
104     }
105   W32kReleaseWindowObject(WindowObject);
106   return(Data);
107 }
108
109 BOOL STDCALL
110 NtUserSetProp(HWND hWnd, ATOM Atom, HANDLE Data)
111 {
112   PWINDOW_OBJECT WindowObject;
113   PPROPERTY Prop;
114
115   WindowObject = W32kGetWindowObject(hWnd);
116   if (WindowObject == NULL)
117     {
118       return(FALSE);
119     }
120
121   Prop = W32kGetProp(WindowObject, Atom);
122   if (Prop == NULL)
123     {
124       Prop = ExAllocatePool(PagedPool, sizeof(PROPERTY));
125       if (Prop == NULL)
126         {
127           W32kReleaseWindowObject(WindowObject);
128           return(FALSE);
129         }
130       Prop->Atom = Atom;
131       InsertTailList(&WindowObject->PropListHead, &Prop->PropListEntry);
132     }
133   Prop->Data = Data;
134   W32kReleaseWindowObject(WindowObject);
135   return(TRUE);
136 }