Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.4 KiB

  1. /***************************************************************************\
  2. * MapPropertyKey
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * Maps a property key string into an atom.
  7. *
  8. * History:
  9. * 21-Dec-1994 JimA Created.
  10. \***************************************************************************/
  11. __inline ATOM MapPropertyKey(
  12. PCWSTR pszKey)
  13. {
  14. #ifdef _USERK_
  15. /*
  16. * Internal properties must use atoms, not strings.
  17. */
  18. UserAssert(!IS_PTR(pszKey));
  19. #else
  20. /*
  21. * Is pszKey an atom? If not, find the atom that matches the string.
  22. * If one doesn't exist, bail out.
  23. */
  24. if (IS_PTR(pszKey))
  25. return GlobalFindAtomW(pszKey);
  26. #endif
  27. return PTR_TO_ID(pszKey);
  28. }
  29. /***************************************************************************\
  30. * FindProp
  31. *
  32. * Search the window's property list for the specified property. pszKey
  33. * could be a string or an atom. If it is a string, convert it to an atom
  34. * before lookup. FindProp will only find internal or external properties
  35. * depending on the fInternal flag.
  36. *
  37. * History:
  38. * 11-14-90 darrinm Rewrote from scratch with new data structures and
  39. * algorithms.
  40. \***************************************************************************/
  41. PPROP _FindProp(
  42. PWND pwnd,
  43. PCWSTR pszKey,
  44. BOOL fInternal)
  45. {
  46. UINT i;
  47. PPROPLIST ppropList;
  48. PPROP pprop;
  49. ATOM atomKey;
  50. /*
  51. * Make sure we have a property list.
  52. */
  53. ppropList = REBASE(pwnd, ppropList);
  54. if (ppropList == NULL)
  55. return NULL;
  56. /*
  57. * Call to the appropriate routine to verify the key name.
  58. */
  59. atomKey = MapPropertyKey(pszKey);
  60. if (atomKey == 0)
  61. return NULL;
  62. /*
  63. * Now we've got the atom, search the list for a property with the
  64. * same atom/name. Make sure to only return internal properties if
  65. * the fInternal flag is set. Do the same for external properties.
  66. */
  67. pprop = ppropList->aprop;
  68. for (i = ppropList->iFirstFree; i > 0; i--) {
  69. if (pprop->atomKey == atomKey) {
  70. if (fInternal) {
  71. if (pprop->fs & PROPF_INTERNAL)
  72. return pprop;
  73. } else {
  74. if (!(pprop->fs & PROPF_INTERNAL))
  75. return pprop;
  76. }
  77. }
  78. pprop++;
  79. }
  80. /*
  81. * Property not found, too bad.
  82. */
  83. return NULL;
  84. }
  85. /***************************************************************************\
  86. * InternalGetProp
  87. *
  88. * Search the window's property list for the specified property and return
  89. * the hData handle from it. If the property is not found, NULL is returned.
  90. *
  91. * History:
  92. * 11-14-90 darrinm Rewrote from scratch with new data structures and
  93. * algorithms.
  94. \***************************************************************************/
  95. HANDLE _GetProp(
  96. PWND pwnd,
  97. PCWSTR pszKey,
  98. BOOL fInternal)
  99. {
  100. PPROP pprop;
  101. /*
  102. * A quick little optimization for that case where the window has no
  103. * properties at all.
  104. */
  105. if (pwnd->ppropList == NULL)
  106. return NULL;
  107. /*
  108. * FindProp does all the work, including converting pszKey to an atom
  109. * (if necessary) for property lookup.
  110. */
  111. pprop = _FindProp(pwnd, pszKey, fInternal);
  112. if (pprop == NULL)
  113. return NULL;
  114. return KHANDLE_TO_HANDLE(pprop->hData);
  115. }