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.

301 lines
8.1 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: srvmsg.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * Includes the mapping table for messages when calling the client.
  7. *
  8. * 04-11-91 ScottLu Created.
  9. \***************************************************************************/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. #define SfnDDEINIT SfnDWORD
  13. #define SfnKERNELONLY SfnDWORD
  14. #ifdef FE_SB
  15. /*
  16. * SfnEMGETSEL, SfnSETSEL, SfnGBGETEDITSEL
  17. */
  18. #define SfnEMGETSEL SfnOPTOUTLPDWORDOPTOUTLPDWORD
  19. #define SfnEMSETSEL SfnDWORD
  20. #define SfnCBGETEDITSEL SfnOPTOUTLPDWORDOPTOUTLPDWORD
  21. #endif // FE_SB
  22. #define MSGFN(func) Sfn ## func
  23. #define FNSCSENDMESSAGE SFNSCSENDMESSAGE
  24. #include <messages.h>
  25. /***************************************************************************\
  26. * fnINLBOXSTRING
  27. *
  28. * Takes a lbox string - a string that treats lParam as a string pointer or
  29. * a DWORD depending on LBS_HASSTRINGS and ownerdraw.
  30. *
  31. * 04-12-91 ScottLu Created.
  32. \***************************************************************************/
  33. LRESULT SfnINLBOXSTRING(
  34. PWND pwnd,
  35. UINT msg,
  36. WPARAM wParam,
  37. LPARAM lParam,
  38. ULONG_PTR xParam,
  39. PROC xpfn,
  40. DWORD dwSCMSFlags,
  41. PSMS psms)
  42. {
  43. DWORD dw;
  44. /*
  45. * See if the control is ownerdraw and does not have the LBS_HASSTRINGS
  46. * style. If so, treat lParam as a DWORD.
  47. */
  48. if (!RevalidateHwnd(HW(pwnd))) {
  49. return 0L;
  50. }
  51. dw = pwnd->style;
  52. if (!(dw & LBS_HASSTRINGS) &&
  53. (dw & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE))) {
  54. /*
  55. * Treat lParam as a dword.
  56. */
  57. return SfnDWORD(pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags, psms);
  58. }
  59. /*
  60. * Treat as a string pointer. Some messages allowed or had certain
  61. * error codes for NULL so send them through the NULL allowed thunk.
  62. * Ventura Publisher does this
  63. */
  64. switch (msg) {
  65. default:
  66. return SfnINSTRING(pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags, psms);
  67. break;
  68. case LB_FINDSTRING:
  69. return SfnINSTRINGNULL(pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags, psms);
  70. break;
  71. }
  72. }
  73. /***************************************************************************\
  74. * SfnOUTLBOXSTRING
  75. *
  76. * Returns an lbox string - a string that treats lParam as a string pointer or
  77. * a DWORD depending on LBS_HASSTRINGS and ownerdraw.
  78. *
  79. * 04-12-91 ScottLu Created.
  80. \***************************************************************************/
  81. LRESULT SfnOUTLBOXSTRING(
  82. PWND pwnd,
  83. UINT msg,
  84. WPARAM wParam,
  85. LPARAM lParam,
  86. ULONG_PTR xParam,
  87. PROC xpfn,
  88. DWORD dwSCMSFlags,
  89. PSMS psms)
  90. {
  91. DWORD dw;
  92. BOOL bNotString;
  93. DWORD dwRet;
  94. TL tlpwnd;
  95. /*
  96. * See if the control is ownerdraw and does not have the LBS_HASSTRINGS
  97. * style. If so, treat lParam as a DWORD.
  98. */
  99. if (!RevalidateHwnd(HW(pwnd))) {
  100. return 0L;
  101. }
  102. dw = pwnd->style;
  103. /*
  104. * See if the control is ownerdraw and does not have the LBS_HASSTRINGS
  105. * style. If so, treat lParam as a DWORD.
  106. */
  107. bNotString = (!(dw & LBS_HASSTRINGS) &&
  108. (dw & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)));
  109. /*
  110. * Make this special call which'll know how to copy this string.
  111. */
  112. ThreadLock(pwnd, &tlpwnd);
  113. dwRet = ClientGetListboxString(pwnd, msg, wParam,
  114. (PLARGE_UNICODE_STRING)lParam,
  115. xParam, xpfn, dwSCMSFlags, bNotString, psms);
  116. ThreadUnlock(&tlpwnd);
  117. return dwRet;
  118. }
  119. /***************************************************************************\
  120. * fnINCBOXSTRING
  121. *
  122. * Takes a lbox string - a string that treats lParam as a string pointer or
  123. * a DWORD depending on CBS_HASSTRINGS and ownerdraw.
  124. *
  125. * 04-12-91 ScottLu Created.
  126. \***************************************************************************/
  127. LRESULT SfnINCBOXSTRING(
  128. PWND pwnd,
  129. UINT msg,
  130. WPARAM wParam,
  131. LPARAM lParam,
  132. ULONG_PTR xParam,
  133. PROC xpfn,
  134. DWORD dwSCMSFlags,
  135. PSMS psms)
  136. {
  137. DWORD dw;
  138. /*
  139. * See if the control is ownerdraw and does not have the CBS_HASSTRINGS
  140. * style. If so, treat lParam as a DWORD.
  141. */
  142. if (!RevalidateHwnd(HW(pwnd))) {
  143. return 0L;
  144. }
  145. dw = pwnd->style;
  146. if (!(dw & CBS_HASSTRINGS) &&
  147. (dw & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE))) {
  148. /*
  149. * Treat lParam as a dword.
  150. */
  151. return SfnDWORD(pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags, psms);
  152. }
  153. /*
  154. * Treat as a string pointer. Some messages allowed or had certain
  155. * error codes for NULL so send them through the NULL allowed thunk.
  156. * Ventura Publisher does this
  157. */
  158. switch (msg) {
  159. default:
  160. return SfnINSTRING(pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags, psms);
  161. break;
  162. case CB_FINDSTRING:
  163. return SfnINSTRINGNULL(pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags, psms);
  164. break;
  165. }
  166. }
  167. /***************************************************************************\
  168. * fnOUTCBOXSTRING
  169. *
  170. * Returns an lbox string - a string that treats lParam as a string pointer or
  171. * a DWORD depending on CBS_HASSTRINGS and ownerdraw.
  172. *
  173. * 04-12-91 ScottLu Created.
  174. \***************************************************************************/
  175. LRESULT SfnOUTCBOXSTRING(
  176. PWND pwnd,
  177. UINT msg,
  178. WPARAM wParam,
  179. LPARAM lParam,
  180. ULONG_PTR xParam,
  181. PROC xpfn,
  182. DWORD dwSCMSFlags,
  183. PSMS psms)
  184. {
  185. DWORD dw;
  186. BOOL bNotString;
  187. DWORD dwRet;
  188. TL tlpwnd;
  189. /*
  190. * See if the control is ownerdraw and does not have the CBS_HASSTRINGS
  191. * style. If so, treat lParam as a DWORD.
  192. */
  193. if (!RevalidateHwnd(HW(pwnd))) {
  194. return 0L;
  195. }
  196. dw = pwnd->style;
  197. bNotString = (!(dw & CBS_HASSTRINGS) &&
  198. (dw & (CBS_OWNERDRAWFIXED | CBS_OWNERDRAWVARIABLE)));
  199. /*
  200. * Make this special call which'll know how to copy this string.
  201. */
  202. ThreadLock(pwnd, &tlpwnd);
  203. dwRet = ClientGetListboxString(pwnd, msg, wParam,
  204. (PLARGE_UNICODE_STRING)lParam,
  205. xParam, xpfn, dwSCMSFlags, bNotString, psms);
  206. ThreadUnlock(&tlpwnd);
  207. return dwRet;
  208. }
  209. /***************************************************************************\
  210. * fnPOWERBROADCAST
  211. *
  212. * Make sure we send the correct message when we resume.
  213. *
  214. * History:
  215. * 02-Dec-1996 JerrySh Created.
  216. * 26-Nov-2001 JasonSch Added code to validate pwnd.
  217. \***************************************************************************/
  218. LRESULT SfnPOWERBROADCAST(
  219. PWND pwnd,
  220. UINT msg,
  221. WPARAM wParam,
  222. LPARAM lParam,
  223. ULONG_PTR xParam,
  224. PROC xpfn,
  225. DWORD dwSCMSFlags,
  226. PSMS psms)
  227. {
  228. if (!RevalidateHwnd(HW(pwnd))) {
  229. return 0L;
  230. }
  231. switch (wParam) {
  232. case PBT_APMQUERYSUSPEND:
  233. SetWF(pwnd, WFGOTQUERYSUSPENDMSG);
  234. break;
  235. case PBT_APMQUERYSUSPENDFAILED:
  236. if (!TestWF(pwnd, WFGOTQUERYSUSPENDMSG))
  237. return 0;
  238. ClrWF(pwnd, WFGOTQUERYSUSPENDMSG);
  239. break;
  240. case PBT_APMSUSPEND:
  241. ClrWF(pwnd, WFGOTQUERYSUSPENDMSG);
  242. SetWF(pwnd, WFGOTSUSPENDMSG);
  243. break;
  244. case PBT_APMRESUMESUSPEND:
  245. case PBT_APMRESUMECRITICAL:
  246. //
  247. // If we're resuming and we never got a suspend message.
  248. // Here we convert our message into a critical resume.
  249. //
  250. if( !TestWF(pwnd, WFGOTSUSPENDMSG) ) {
  251. wParam = PBT_APMRESUMECRITICAL;
  252. }
  253. //
  254. // Now clear any 'suspend' messages that our
  255. // window may have previously recieved.
  256. //
  257. ClrWF(pwnd, WFGOTQUERYSUSPENDMSG);
  258. ClrWF(pwnd, WFGOTSUSPENDMSG);
  259. break;
  260. }
  261. return SfnDWORD(pwnd, msg, wParam, lParam, xParam, xpfn, dwSCMSFlags, psms);
  262. }