Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

win32wbaseprop.cpp

Go to the documentation of this file.
00001 /* $Id: win32wbaseprop.cpp,v 1.1 2000/05/05 11:32:38 sandervl Exp $ */
00002 /*
00003  * Window properties
00004  *
00005  * Ported Wine code (win\property.c):
00006  * Copyright 1995, 1996 Alexandre Julliard
00007  *
00008  * TODO: Not thread safe!!
00009  *
00010  * Project Odin Software License can be found in LICENSE.TXT
00011  *
00012  */
00013 #include <string.h>
00014 #include <user32.h>
00015 #include <heapstring.h>
00016 #include <misc.h>
00017 #include "win32wbase.h"
00018 
00019 #define DBG_LOCALLOG    DBG_win32wbaseprop
00020 #include "dbglocal.h"
00021 
00022 /***********************************************************************
00023  *           PROP_FindProp
00024  */
00025 PROPERTY *Win32BaseWindow::findWindowProperty(LPCSTR str)
00026 {
00027   PROPERTY *prop;
00028   ATOM      atom;
00029 
00030     if (HIWORD(str))
00031     {
00032         atom = GlobalFindAtomA(str);
00033         for (prop = propertyList; prop; prop = prop->next)
00034         {
00035             if (HIWORD(prop->string))
00036             {
00037                  if (!lstrcmpiA( prop->string, str )) goto END;
00038             }
00039             else if (LOWORD(prop->string) == atom) goto END;
00040         }
00041     }
00042     else  /* atom */
00043     {
00044         atom = LOWORD(str);
00045         for (prop = propertyList; (prop); prop = prop->next)
00046         {
00047             if (HIWORD(prop->string))
00048             {
00049                  if (GlobalFindAtomA( prop->string ) == atom) goto END;
00050             }
00051             else if (LOWORD(prop->string) == atom) goto END;
00052         }
00053     }
00054     if(HIWORD(str)) {
00055          dprintf2(("Property %s for window %x NOT FOUND!", str, getWindowHandle()));
00056     }
00057     else dprintf2(("Property %x for window %x NOT FOUND!", str, getWindowHandle()));
00058 
00059     prop = NULL;
00060 END:
00061     return prop;
00062 }
00063 
00064 /***********************************************************************
00065  *           GetPropA   (USER32.281)
00066  */
00067 HANDLE Win32BaseWindow::getProp(LPCSTR str)
00068 {
00069     PROPERTY *prop = findWindowProperty(str);
00070 
00071     if(HIWORD(str)) {
00072          dprintf2(("GetProp %x %s %x", getWindowHandle, str, prop ? prop->handle : 0));
00073     }
00074     else dprintf2(("GetProp %x %x %x", getWindowHandle, str, prop ? prop->handle : 0));
00075 
00076     return prop ? prop->handle : 0;
00077 }
00078 
00079 /***********************************************************************
00080  *           SetPropA   (USER32.497)
00081  */
00082 BOOL Win32BaseWindow::setProp(LPCSTR str, HANDLE handle)
00083 {
00084     PROPERTY *prop;
00085 
00086     if (HIWORD(str)) {
00087          dprintf2(("SetProp %x %s %x", getWindowHandle, str, handle));
00088     }
00089     else dprintf2(("SetProp %x %x %x", getWindowHandle, str, handle));
00090 
00091     if (!(prop = findWindowProperty(str)))
00092     {
00093         /* We need to create it */
00094         if (!(prop = (PROPERTY *)HeapAlloc(GetProcessHeap(), 0, sizeof(*prop) )))
00095         {
00096              dprintf(("setProp: malloc failed!!"));
00097              return FALSE;
00098         }
00099         if(HIWORD(str))
00100         {
00101              if (!(prop->string = HEAP_strdupA(GetProcessHeap(), 0, str)))
00102              {
00103                 HeapFree( GetProcessHeap(), 0, prop );
00104                 return FALSE;
00105              }
00106         }
00107         else prop->string = (char *)str;  //atom
00108 
00109         prop->next   = propertyList;
00110         propertyList = prop;
00111     }
00112     prop->handle = handle;
00113     return TRUE;
00114 }
00115 
00116 /***********************************************************************
00117  *           RemovePropA   (USER32.442)
00118  */
00119 HANDLE Win32BaseWindow::removeProp(LPCSTR str)
00120 {
00121     ATOM atom;
00122     HANDLE handle;
00123     PROPERTY **pprop, *prop;
00124 
00125     if (HIWORD(str)) {
00126          dprintf2(("RemoveProp %x %s", getWindowHandle(), str ));
00127     }
00128     else dprintf2(("RemoveProp %x %x", getWindowHandle(), str ));
00129 
00130     if (HIWORD(str))
00131     {
00132         atom = GlobalFindAtomA( str );
00133         for (pprop=(PROPERTY**)&propertyList; (*pprop); pprop = &(*pprop)->next)
00134         {
00135             if (HIWORD((*pprop)->string))
00136             {
00137                  if (!lstrcmpiA( (*pprop)->string, str )) break;
00138             }
00139             else if (LOWORD((*pprop)->string) == atom) break;
00140         }
00141     }
00142     else  /* atom */
00143     {
00144         atom = LOWORD(str);
00145         for (pprop=(PROPERTY**)&propertyList; (*pprop); pprop = &(*pprop)->next)
00146         {
00147             if (HIWORD((*pprop)->string))
00148             {
00149                  if (GlobalFindAtomA( (*pprop)->string ) == atom) break;
00150             }
00151             else if (LOWORD((*pprop)->string) == atom) break;
00152         }
00153     }
00154     if (!*pprop) return 0;
00155 
00156     prop   = *pprop;
00157     handle = prop->handle;
00158     *pprop = prop->next;
00159     if(HIWORD(prop->string))
00160         HeapFree(GetProcessHeap(), 0, prop->string);
00161     HeapFree( GetProcessHeap(), 0, prop );
00162     return handle;
00163 }
00164 
00165 /***********************************************************************
00166  *           PROPERTY_RemoveWindowProps
00167  *
00168  * Remove all properties of a window.
00169  */
00170 void Win32BaseWindow::removeWindowProps()
00171 {
00172     PROPERTY *prop, *next;
00173 
00174     for (prop = propertyList; (prop); prop = next)
00175     {
00176         next = prop->next;
00177         if(HIWORD(prop->string))
00178             HeapFree(GetProcessHeap(), 0, prop->string);
00179         HeapFree(GetProcessHeap(), 0, prop);
00180     }
00181     propertyList = NULL;
00182 }
00183 
00184 /***********************************************************************
00185  *           EnumPropsExA   (USER32.187)
00186  */
00187 INT Win32BaseWindow::enumPropsExA(PROPENUMPROCEXA func, LPARAM lParam)
00188 {
00189     PROPERTY *prop, *next;
00190     INT ret = -1;
00191 
00192     dprintf(("EnumPropsExA %x %x %x", getWindowHandle, func, lParam));
00193 
00194     for (prop = propertyList; (prop); prop = next)
00195     {
00196         /* Already get the next in case the callback */
00197         /* function removes the current property.    */
00198         next = prop->next;
00199 
00200         if(HIWORD(prop->string)) {
00201              dprintf2(("EnumPropsExA: Callback: handle=%08x str=%s", prop->handle, prop->string));
00202         }
00203         else dprintf2(("EnumPropsExA: Callback: handle=%08x str=%x", prop->handle, prop->string));
00204 
00205         ret = func( getWindowHandle(), prop->string, prop->handle, lParam );
00206         if (!ret) break;
00207     }
00208     return ret;
00209 }
00210 
00211 
00212 /***********************************************************************
00213  *           EnumPropsExW   (USER32.188)
00214  */
00215 INT Win32BaseWindow::enumPropsExW(PROPENUMPROCEXW func, LPARAM lParam)
00216 {
00217     PROPERTY *prop, *next;
00218     INT ret = -1;
00219 
00220     dprintf(("EnumPropsExW %x %x %x", getWindowHandle, func, lParam));
00221 
00222     for (prop = propertyList; (prop); prop = next)
00223     {
00224         /* Already get the next in case the callback */
00225         /* function removes the current property.    */
00226         next = prop->next;
00227 
00228         if(HIWORD(prop->string)) {
00229              dprintf2(("EnumPropsExW: Callback: handle=%08x str=%s", prop->handle, prop->string));
00230         }
00231         else dprintf2(("EnumPropsExW: Callback: handle=%08x str=%x", prop->handle, prop->string));
00232 
00233         if (HIWORD(prop->string))
00234         {
00235             LPWSTR str = HEAP_strdupAtoW( GetProcessHeap(), 0, prop->string );
00236             ret = func( getWindowHandle(), str, prop->handle, lParam );
00237             HeapFree( GetProcessHeap(), 0, str );
00238         }
00239         else
00240             ret = func( getWindowHandle(), (LPCWSTR)(UINT)LOWORD( prop->string ),
00241                         prop->handle, lParam );
00242         if (!ret) break;
00243     }
00244     return ret;
00245 }
00246 //******************************************************************************
00247 //******************************************************************************

Generated on Wed Jan 23 23:17:48 2002 for ODIN-user32 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001