4 * Copyright 1995, 1996 Alexandre Julliard
7 #define NO_TRANSITION_TYPES /* This file is Win32-clean */
17 typedef struct tagPROPERTY
19 struct tagPROPERTY
*next
; /* Next property in window list */
20 HANDLE32 handle
; /* User's data */
21 LPSTR string
; /* Property string (or atom) */
25 /***********************************************************************
28 static PROPERTY
*PROP_FindProp( HWND32 hwnd
, LPCSTR str
)
31 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
33 if (!pWnd
) return NULL
;
36 for (prop
= pWnd
->pProp
; prop
; prop
= prop
->next
)
37 if (HIWORD(prop
->string
) && !lstrcmpi32A( prop
->string
, str
))
42 for (prop
= pWnd
->pProp
; (prop
); prop
= prop
->next
)
43 if (!HIWORD(prop
->string
) && (LOWORD(prop
->string
) == LOWORD(str
)))
50 /***********************************************************************
53 HANDLE16
GetProp16( HWND16 hwnd
, LPCSTR str
)
55 return (HANDLE16
)GetProp32A( hwnd
, str
);
59 /***********************************************************************
60 * GetProp32A (USER32.280)
62 HANDLE32
GetProp32A( HWND32 hwnd
, LPCSTR str
)
64 PROPERTY
*prop
= PROP_FindProp( hwnd
, str
);
67 dprintf_prop( stddeb
, "GetProp(%08x,'%s'): returning %08x\n",
68 hwnd
, str
, prop
? prop
->handle
: 0 );
70 dprintf_prop( stddeb
, "GetProp(%08x,#%04x): returning %08x\n",
71 hwnd
, LOWORD(str
), prop
? prop
->handle
: 0 );
73 return prop
? prop
->handle
: 0;
77 /***********************************************************************
78 * GetProp32W (USER32.281)
80 HANDLE32
GetProp32W( HWND32 hwnd
, LPCWSTR str
)
85 if (!HIWORD(str
)) return GetProp32A( hwnd
, (LPCSTR
)(UINT32
)LOWORD(str
) );
86 strA
= STRING32_DupUniToAnsi( str
);
87 ret
= GetProp32A( hwnd
, strA
);
93 /***********************************************************************
96 BOOL16
SetProp16( HWND16 hwnd
, LPCSTR str
, HANDLE16 handle
)
98 return (BOOL16
)SetProp32A( hwnd
, str
, handle
);
102 /***********************************************************************
103 * SetProp32A (USER32.496)
105 BOOL32
SetProp32A( HWND32 hwnd
, LPCSTR str
, HANDLE32 handle
)
110 dprintf_prop( stddeb
, "SetProp: %04x '%s' %08x\n", hwnd
, str
, handle
);
112 dprintf_prop( stddeb
, "SetProp: %04x #%04x %08x\n",
113 hwnd
, LOWORD(str
), handle
);
115 if (!(prop
= PROP_FindProp( hwnd
, str
)))
117 /* We need to create it */
118 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
119 if (!pWnd
) return FALSE
;
120 if (!(prop
= HeapAlloc( SystemHeap
, 0, sizeof(*prop
) ))) return FALSE
;
121 if (!(prop
->string
= SEGPTR_STRDUP(str
)))
123 HeapFree( SystemHeap
, 0, prop
);
126 prop
->next
= pWnd
->pProp
;
129 prop
->handle
= handle
;
134 /***********************************************************************
135 * SetProp32W (USER32.497)
137 BOOL32
SetProp32W( HWND32 hwnd
, LPCWSTR str
, HANDLE32 handle
)
143 return SetProp32A( hwnd
, (LPCSTR
)(UINT32
)LOWORD(str
), handle
);
144 strA
= STRING32_DupUniToAnsi( str
);
145 ret
= SetProp32A( hwnd
, strA
, handle
);
151 /***********************************************************************
152 * RemoveProp16 (USER.24)
154 HANDLE16
RemoveProp16( HWND16 hwnd
, LPCSTR str
)
156 return (HANDLE16
)RemoveProp32A( hwnd
, str
);
160 /***********************************************************************
161 * RemoveProp32A (USER32.441)
163 HANDLE32
RemoveProp32A( HWND32 hwnd
, LPCSTR str
)
166 PROPERTY
**pprop
, *prop
;
167 WND
*pWnd
= WIN_FindWndPtr( hwnd
);
170 dprintf_prop( stddeb
, "RemoveProp: %04x '%s'\n", hwnd
, str
);
172 dprintf_prop( stddeb
, "RemoveProp: %04x #%04x\n", hwnd
, LOWORD(str
));
175 if (!pWnd
) return NULL
;
178 for (pprop
=(PROPERTY
**)&pWnd
->pProp
; (*pprop
); pprop
= &(*pprop
)->next
)
179 if (HIWORD((*pprop
)->string
) &&
180 !lstrcmpi32A( (*pprop
)->string
, str
)) break;
184 for (pprop
=(PROPERTY
**)&pWnd
->pProp
; (*pprop
); pprop
= &(*pprop
)->next
)
185 if (!HIWORD((*pprop
)->string
) &&
186 (LOWORD((*pprop
)->string
) == LOWORD(str
))) break;
188 if (!*pprop
) return 0;
190 handle
= prop
->handle
;
192 SEGPTR_FREE(prop
->string
);
193 HeapFree( SystemHeap
, 0, prop
);
198 /***********************************************************************
199 * RemoveProp32W (USER32.442)
201 HANDLE32
RemoveProp32W( HWND32 hwnd
, LPCWSTR str
)
207 return RemoveProp32A( hwnd
, (LPCSTR
)(UINT32
)LOWORD(str
) );
208 strA
= STRING32_DupUniToAnsi( str
);
209 ret
= RemoveProp32A( hwnd
, strA
);
215 /***********************************************************************
216 * PROPERTY_RemoveWindowProps
218 * Remove all properties of a window.
220 void PROPERTY_RemoveWindowProps( WND
*pWnd
)
222 PROPERTY
*prop
, *next
;
224 for (prop
= pWnd
->pProp
; (prop
); prop
= next
)
227 SEGPTR_FREE( prop
->string
);
228 HeapFree( SystemHeap
, 0, prop
);
234 /***********************************************************************
235 * EnumProps16 (USER.27)
237 INT16
EnumProps16( HWND16 hwnd
, PROPENUMPROC16 func
)
239 PROPERTY
*prop
, *next
;
243 dprintf_prop( stddeb
, "EnumProps: %04x %08x\n", hwnd
, (UINT32
)func
);
244 if (!(pWnd
= WIN_FindWndPtr( hwnd
))) return -1;
245 for (prop
= pWnd
->pProp
; (prop
); prop
= next
)
247 /* Already get the next in case the callback */
248 /* function removes the current property. */
251 dprintf_prop( stddeb
, " Callback: handle=%08x str='%s'\n",
252 prop
->handle
, prop
->string
);
253 ret
= func( hwnd
, SEGPTR_GET(prop
->string
), prop
->handle
);
260 /***********************************************************************
261 * EnumProps32A (USER32.185)
263 INT32
EnumProps32A( HWND32 hwnd
, PROPENUMPROC32A func
)
265 return EnumPropsEx32A( hwnd
, (PROPENUMPROCEX32A
)func
, 0 );
269 /***********************************************************************
270 * EnumProps32W (USER32.188)
272 INT32
EnumProps32W( HWND32 hwnd
, PROPENUMPROC32W func
)
274 return EnumPropsEx32W( hwnd
, (PROPENUMPROCEX32W
)func
, 0 );
278 /***********************************************************************
279 * EnumPropsEx32A (USER32.186)
281 INT32
EnumPropsEx32A( HWND32 hwnd
, PROPENUMPROCEX32A func
, LPARAM lParam
)
283 PROPERTY
*prop
, *next
;
287 dprintf_prop( stddeb
, "EnumPropsEx32A: %04x %08x %08lx\n",
288 hwnd
, (UINT32
)func
, lParam
);
289 if (!(pWnd
= WIN_FindWndPtr( hwnd
))) return -1;
290 for (prop
= pWnd
->pProp
; (prop
); prop
= next
)
292 /* Already get the next in case the callback */
293 /* function removes the current property. */
296 dprintf_prop( stddeb
, " Callback: handle=%08x str='%s'\n",
297 prop
->handle
, prop
->string
);
298 ret
= func( hwnd
, prop
->string
, prop
->handle
, lParam
);
305 /***********************************************************************
306 * EnumPropsEx32W (USER32.187)
308 INT32
EnumPropsEx32W( HWND32 hwnd
, PROPENUMPROCEX32W func
, LPARAM lParam
)
310 PROPERTY
*prop
, *next
;
314 dprintf_prop( stddeb
, "EnumPropsEx32W: %04x %08x %08lx\n",
315 hwnd
, (UINT32
)func
, lParam
);
316 if (!(pWnd
= WIN_FindWndPtr( hwnd
))) return -1;
317 for (prop
= pWnd
->pProp
; (prop
); prop
= next
)
319 /* Already get the next in case the callback */
320 /* function removes the current property. */
323 dprintf_prop( stddeb
, " Callback: handle=%08x str='%s'\n",
324 prop
->handle
, prop
->string
);
325 if (HIWORD(prop
->string
))
327 LPWSTR str
= STRING32_DupAnsiToUni( prop
->string
);
328 ret
= func( hwnd
, str
, prop
->handle
, lParam
);
332 ret
= func( hwnd
, (LPCWSTR
)(UINT32
)LOWORD( prop
->string
),
333 prop
->handle
, lParam
);