source: trunk/src/user32/win32wbaseprop.cpp@ 10367

Last change on this file since 10367 was 10031, checked in by sandervl, 22 years ago

KSO: Properties allocated from shared memory & Fake window updates & SW_SHOWDEFAULT update

File size: 6.9 KB
Line 
1/* $Id: win32wbaseprop.cpp,v 1.2 2003-04-23 18:01:00 sandervl Exp $ */
2/*
3 * Window properties
4 *
5 * Ported Wine code (win\property.c):
6 * Copyright 1995, 1996 Alexandre Julliard
7 *
8 * TODO: Not thread safe!!
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 */
13#include <string.h>
14#include <user32.h>
15#include <heapstring.h>
16#include <misc.h>
17#include "win32wbase.h"
18
19#define DBG_LOCALLOG DBG_win32wbaseprop
20#include "dbglocal.h"
21
22/***********************************************************************
23 * PROP_FindProp
24 */
25PROPERTY *Win32BaseWindow::findWindowProperty(LPCSTR str)
26{
27 PROPERTY *prop;
28 ATOM atom;
29
30 if (HIWORD(str))
31 {
32 atom = GlobalFindAtomA(str);
33 for (prop = propertyList; prop; prop = prop->next)
34 {
35 if (HIWORD(prop->string))
36 {
37 if (!lstrcmpiA( prop->string, str )) goto END;
38 }
39 else if (LOWORD(prop->string) == atom) goto END;
40 }
41 }
42 else /* atom */
43 {
44 atom = LOWORD(str);
45 for (prop = propertyList; (prop); prop = prop->next)
46 {
47 if (HIWORD(prop->string))
48 {
49 if (GlobalFindAtomA( prop->string ) == atom) goto END;
50 }
51 else if (LOWORD(prop->string) == atom) goto END;
52 }
53 }
54 if(HIWORD(str)) {
55 dprintf2(("Property %s for window %x NOT FOUND!", str, getWindowHandle()));
56 }
57 else dprintf2(("Property %x for window %x NOT FOUND!", str, getWindowHandle()));
58
59 prop = NULL;
60END:
61 return prop;
62}
63
64/***********************************************************************
65 * GetPropA (USER32.281)
66 */
67HANDLE Win32BaseWindow::getProp(LPCSTR str)
68{
69 PROPERTY *prop = findWindowProperty(str);
70
71 if(HIWORD(str)) {
72 dprintf2(("GetProp %x %s %x", getWindowHandle, str, prop ? prop->handle : 0));
73 }
74 else dprintf2(("GetProp %x %x %x", getWindowHandle, str, prop ? prop->handle : 0));
75
76 return prop ? prop->handle : 0;
77}
78
79/***********************************************************************
80 * SetPropA (USER32.497)
81 */
82BOOL Win32BaseWindow::setProp(LPCSTR str, HANDLE handle)
83{
84 PROPERTY *prop;
85
86 if (HIWORD(str)) {
87 dprintf2(("SetProp %x %s %x", getWindowHandle, str, handle));
88 }
89 else dprintf2(("SetProp %x %x %x", getWindowHandle, str, handle));
90
91 if (!(prop = findWindowProperty(str)))
92 {
93 /* We need to create it */
94 if (!(prop = (PROPERTY *)_smalloc(sizeof(*prop) )))
95 {
96 dprintf(("setProp: malloc failed!!"));
97 return FALSE;
98 }
99 if(HIWORD(str))
100 {
101 unsigned cch = strlen(str) + 1;
102 if (!(prop->string = (LPSTR)_smalloc(cch)))
103 {
104 _sfree(prop);
105 return FALSE;
106 }
107 memcpy(prop->string, str, cch);
108 }
109 else prop->string = (char *)str; //atom
110
111 prop->next = propertyList;
112 propertyList = prop;
113 }
114 prop->handle = handle;
115 return TRUE;
116}
117
118/***********************************************************************
119 * RemovePropA (USER32.442)
120 */
121HANDLE Win32BaseWindow::removeProp(LPCSTR str)
122{
123 ATOM atom;
124 HANDLE handle;
125 PROPERTY **pprop, *prop;
126
127 if (HIWORD(str)) {
128 dprintf2(("RemoveProp %x %s", getWindowHandle(), str ));
129 }
130 else dprintf2(("RemoveProp %x %x", getWindowHandle(), str ));
131
132 if (HIWORD(str))
133 {
134 atom = GlobalFindAtomA( str );
135 for (pprop=(PROPERTY**)&propertyList; (*pprop); pprop = &(*pprop)->next)
136 {
137 if (HIWORD((*pprop)->string))
138 {
139 if (!lstrcmpiA( (*pprop)->string, str )) break;
140 }
141 else if (LOWORD((*pprop)->string) == atom) break;
142 }
143 }
144 else /* atom */
145 {
146 atom = LOWORD(str);
147 for (pprop=(PROPERTY**)&propertyList; (*pprop); pprop = &(*pprop)->next)
148 {
149 if (HIWORD((*pprop)->string))
150 {
151 if (GlobalFindAtomA( (*pprop)->string ) == atom) break;
152 }
153 else if (LOWORD((*pprop)->string) == atom) break;
154 }
155 }
156 if (!*pprop) return 0;
157
158 prop = *pprop;
159 handle = prop->handle;
160 *pprop = prop->next;
161 if(HIWORD(prop->string))
162 _sfree(prop->string);
163 _sfree(prop);
164 return handle;
165}
166
167/***********************************************************************
168 * PROPERTY_RemoveWindowProps
169 *
170 * Remove all properties of a window.
171 */
172void Win32BaseWindow::removeWindowProps()
173{
174 PROPERTY *prop, *next;
175
176 for (prop = propertyList; (prop); prop = next)
177 {
178 next = prop->next;
179 if(HIWORD(prop->string))
180 _sfree(prop->string);
181 _sfree(prop);
182 }
183 propertyList = NULL;
184}
185
186/***********************************************************************
187 * EnumPropsExA (USER32.187)
188 */
189INT Win32BaseWindow::enumPropsExA(PROPENUMPROCEXA func, LPARAM lParam)
190{
191 PROPERTY *prop, *next;
192 INT ret = -1;
193
194 dprintf(("EnumPropsExA %x %x %x", getWindowHandle, func, lParam));
195
196 for (prop = propertyList; (prop); prop = next)
197 {
198 /* Already get the next in case the callback */
199 /* function removes the current property. */
200 next = prop->next;
201
202 if(HIWORD(prop->string)) {
203 dprintf2(("EnumPropsExA: Callback: handle=%08x str=%s", prop->handle, prop->string));
204 }
205 else dprintf2(("EnumPropsExA: Callback: handle=%08x str=%x", prop->handle, prop->string));
206
207 ret = func( getWindowHandle(), prop->string, prop->handle, lParam );
208 if (!ret) break;
209 }
210 return ret;
211}
212
213
214/***********************************************************************
215 * EnumPropsExW (USER32.188)
216 */
217INT Win32BaseWindow::enumPropsExW(PROPENUMPROCEXW func, LPARAM lParam)
218{
219 PROPERTY *prop, *next;
220 INT ret = -1;
221
222 dprintf(("EnumPropsExW %x %x %x", getWindowHandle, func, lParam));
223
224 for (prop = propertyList; (prop); prop = next)
225 {
226 /* Already get the next in case the callback */
227 /* function removes the current property. */
228 next = prop->next;
229
230 if(HIWORD(prop->string)) {
231 dprintf2(("EnumPropsExW: Callback: handle=%08x str=%s", prop->handle, prop->string));
232 }
233 else dprintf2(("EnumPropsExW: Callback: handle=%08x str=%x", prop->handle, prop->string));
234
235 if (HIWORD(prop->string))
236 {
237 LPWSTR str = HEAP_strdupAtoW( GetProcessHeap(), 0, prop->string );
238 ret = func( getWindowHandle(), str, prop->handle, lParam );
239 HeapFree( GetProcessHeap(), 0, str );
240 }
241 else
242 ret = func( getWindowHandle(), (LPCWSTR)(UINT)LOWORD( prop->string ),
243 prop->handle, lParam );
244 if (!ret) break;
245 }
246 return ret;
247}
248//******************************************************************************
249//******************************************************************************
Note: See TracBrowser for help on using the repository browser.