test: winprop.c Source File

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# winprop.c

Go to the documentation of this file.

    00001
    00002 /***************************************************************************\
    00003 * MapPropertyKey
    00004 *
    00005 * Copyright (c) 1985 - 1999, Microsoft Corporation
    00006 *
    00007 * Maps a property key string into an atom.
    00008 *
    00009 * History:
    00010 * 21-Dec-1994   JimA    Created.
    00011 \***************************************************************************/
    00012
    00013 __inline ATOM MapPropertyKey(
    00014     PCWSTR pszKey)
    00015 {
    00016 #ifdef _USERK_
    00017     /*
    00018      * Internal properties must use atoms, not strings.
    00019      */
    00020     UserAssert(!IS_PTR(pszKey));
    00021 #else
    00022     /*
    00023      * Is pszKey an atom?  If not, find the atom that matches the string.
    00024      * If one doesn't exist, bail out.
    00025      */
    00026     if (IS_PTR(pszKey))
    00027         return GlobalFindAtomW(pszKey);
    00028 #endif
    00029
    00030     return PTR_TO_ID(pszKey);
    00031 }
    00032
    00033 /***************************************************************************\
    00034 * FindProp
    00035 *
    00036 * Search the window's property list for the specified property.  pszKey
    00037 * could be a string or an atom.  If it is a string, convert it to an atom
    00038 * before lookup.  FindProp will only find internal or external properties
    00039 * depending on the fInternal flag.
    00040 *
    00041 * History:
    00042 * 11-14-90 darrinm      Rewrote from scratch with new data structures and
    00043 *                       algorithms.
    00044 \***************************************************************************/
    00045
    00046 PPROP _FindProp(
    00047     PWND pwnd,
    00048     PCWSTR pszKey,
    00049     BOOL fInternal)
    00050 {
    00051     UINT i;
    00052     PPROPLIST ppropList;
    00053     PPROP pprop;
    00054     ATOM atomKey;
    00055
    00056     /*
    00057      * Make sure we have a property list.
    00058      */
    00059     ppropList = REBASE(pwnd, ppropList);
    00060     if (ppropList == NULL)
    00061         return NULL;
    00062
    00063     /*
    00064      * Call to the appropriate routine to verify the key name.
    00065      */
    00066     atomKey = MapPropertyKey(pszKey);
    00067     if (atomKey == 0)
    00068         return NULL;
    00069
    00070     /*
    00071      * Now we've got the atom, search the list for a property with the
    00072      * same atom/name.  Make sure to only return internal properties if
    00073      * the fInternal flag is set.  Do the same for external properties.
    00074      */
    00075     pprop = ppropList->aprop;
    00076     for (i = ppropList->iFirstFree; i > 0; i--) {
    00077         if (pprop->atomKey == atomKey) {
    00078             if (fInternal) {
    00079                 if (pprop->fs & PROPF_INTERNAL)
    00080                     return pprop;
    00081             } else {
    00082                 if (!(pprop->fs & PROPF_INTERNAL))
    00083                     return pprop;
    00084             }
    00085         }
    00086         pprop++;
    00087     }
    00088
    00089     /*
    00090      * Property not found, too bad.
    00091      */
    00092     return NULL;
    00093 }
    00094
    00095 /***************************************************************************\
    00096 * InternalGetProp
    00097 *
    00098 * Search the window's property list for the specified property and return
    00099 * the hData handle from it.  If the property is not found, NULL is returned.
    00100 *
    00101 * History:
    00102 * 11-14-90 darrinm      Rewrote from scratch with new data structures and
    00103 *                       algorithms.
    00104 \***************************************************************************/
    00105
    00106 HANDLE _GetProp(
    00107     PWND pwnd,
    00108     PCWSTR pszKey,
    00109     BOOL fInternal)
    00110 {
    00111     PPROP pprop;
    00112
    00113     /*
    00114      * A quick little optimization for that case where the window has no
    00115      * properties at all.
    00116      */
    00117     if (pwnd->ppropList == NULL)
    00118         return NULL;
    00119
    00120     /*
    00121      * FindProp does all the work, including converting pszKey to an atom
    00122      * (if necessary) for property lookup.
    00123      */
    00124     pprop = _FindProp(pwnd, pszKey, fInternal);
    00125     if (pprop == NULL)
    00126         return NULL;
    00127
    00128     return pprop->hData;
    00129 }