4 * Copyright 1995 Alexandre Julliard
12 /* #define DEBUG_PROP */
18 HANDLE next; /* Next property in window list */
19 ATOM atom; /* Atom (or 0 if string) */
20 HANDLE hData; /* User's data */
21 char string[1]; /* Property string */
25 /***********************************************************************
28 BOOL SetProp( HWND hwnd, SEGPTR str, HANDLE hData )
34 dprintf_prop( stddeb, "SetProp: %04x %08lx %04x\n", hwnd, str, hData );
35 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE;
36 hProp = USER_HEAP_ALLOC( sizeof(PROPERTY) +
37 (HIWORD(str) ? strlen(PTR_SEG_TO_LIN(str)) : 0 ));
38 if (!hProp) return FALSE;
39 prop = (PROPERTY *) USER_HEAP_LIN_ADDR( hProp );
40 if (HIWORD(str)) /* string */
43 strcpy( prop->string, PTR_SEG_TO_LIN(str) );
47 prop->atom = LOWORD(str);
48 prop->string[0] = '\0';
51 prop->next = wndPtr->hProp;
52 wndPtr->hProp = hProp;
57 /***********************************************************************
60 HANDLE GetProp( HWND hwnd, SEGPTR str )
65 dprintf_prop( stddeb, "GetProp: %04x %08lx\n", hwnd, str );
66 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
67 hProp = wndPtr->hProp;
70 PROPERTY *prop = (PROPERTY *)USER_HEAP_LIN_ADDR(hProp);
73 if (!prop->atom && !strcasecmp( prop->string, PTR_SEG_TO_LIN(str)))
76 else if (prop->atom && (prop->atom == LOWORD(str))) return prop->hData;
83 /***********************************************************************
84 * RemoveProp (USER.24)
86 HANDLE RemoveProp( HWND hwnd, SEGPTR str )
91 dprintf_prop( stddeb, "RemoveProp: %04x %08lx\n", hwnd, str );
92 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
93 hProp = &wndPtr->hProp;
96 PROPERTY *prop = (PROPERTY *)USER_HEAP_LIN_ADDR( *hProp );
97 if ((HIWORD(str) && !prop->atom &&
98 !strcasecmp( prop->string, PTR_SEG_TO_LIN(str))) ||
99 (!HIWORD(str) && prop->atom && (prop->atom == LOWORD(str))))
101 HANDLE hNext = prop->next;
102 HANDLE hData = prop->hData;
103 USER_HEAP_FREE( *hProp );
113 /***********************************************************************
114 * EnumProps (USER.27)
116 int EnumProps( HWND hwnd, FARPROC func )
122 dprintf_prop( stddeb, "EnumProps: %04x %08lx\n", hwnd, (LONG)func );
123 if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
124 hProp = wndPtr->hProp;
127 PROPERTY *prop = (PROPERTY *)USER_HEAP_LIN_ADDR(hProp);
129 dprintf_prop( stddeb, " Callback: atom=%04x data=%04x str='%s'\n",
130 prop->atom, prop->hData, prop->string );
132 /* Already get the next in case the callback */
133 /* function removes the current property. */
135 ret = CallEnumPropProc( func, hwnd,
136 prop->atom ? MAKELONG( prop->atom, 0 ) :
137 USER_HEAP_SEG_ADDR(hProp) +
138 ((int)prop->string - (int)prop),