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.

222 lines
6.1 KiB

  1. /****************************************************************************\
  2. * Module Name: minmax.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * Misc util functions
  7. *
  8. * 10-25-90 MikeHar Ported from Windows.
  9. * 14-Feb-1991 mikeke Added Revalidation code (None)
  10. \****************************************************************************/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. VOID ZapActiveAndFocus(
  14. VOID)
  15. {
  16. PQ pq = PtiCurrent()->pq;
  17. Unlock(&pq->spwndActive);
  18. Unlock(&pq->spwndFocus);
  19. }
  20. VOID SetDialogPointer(
  21. PWND pwnd,
  22. LONG_PTR lPtr)
  23. {
  24. if (pwnd->cbwndExtra < DLGWINDOWEXTRA ||
  25. TestWF(pwnd, WFSERVERSIDEPROC) ||
  26. PpiCurrent() != GETPTI(pwnd)->ppi) {
  27. RIPMSG1(RIP_WARNING, "SetDialogPointer: Unexpected pwnd 0x%p", pwnd);
  28. return;
  29. }
  30. ((PDIALOG)pwnd)->pdlg = (PDLG)lPtr;
  31. if (lPtr == 0) {
  32. pwnd->fnid |= FNID_CLEANEDUP_BIT;
  33. ClrWF(pwnd, WFDIALOGWINDOW);
  34. } else {
  35. if (pwnd->fnid == 0) {
  36. pwnd->fnid = FNID_DIALOG;
  37. }
  38. SetWF(pwnd, WFDIALOGWINDOW);
  39. }
  40. }
  41. BOOL _SetProgmanWindow(
  42. PWND pwnd)
  43. {
  44. PDESKTOPINFO pdeskinfo = GETDESKINFO(PtiCurrent());
  45. if (pwnd != NULL) {
  46. /*
  47. * Fail the call if another progman window exists.
  48. */
  49. if (pdeskinfo->spwndProgman != NULL) {
  50. RIPERR0(ERROR_ACCESS_DENIED,
  51. RIP_WARNING,
  52. "Progman window already set");
  53. return FALSE;
  54. }
  55. }
  56. Lock(&pdeskinfo->spwndProgman, pwnd);
  57. return TRUE;
  58. }
  59. BOOL _SetTaskmanWindow(
  60. PWND pwnd)
  61. {
  62. PDESKTOPINFO pdeskinfo = GETDESKINFO(PtiCurrent());
  63. if (pwnd != NULL) {
  64. /*
  65. * Fail the call if another taskman window exists.
  66. */
  67. if (pdeskinfo->spwndTaskman != NULL) {
  68. RIPERR0(ERROR_ACCESS_DENIED,
  69. RIP_WARNING,
  70. "Taskman window already set");
  71. return FALSE;
  72. }
  73. }
  74. Lock(&pdeskinfo->spwndTaskman, pwnd);
  75. return TRUE;
  76. }
  77. /***************************************************************************\
  78. * SetShellWindow
  79. *
  80. * Returns true if shell window is successfully set. Note that we return
  81. * FALSE if a shell window already exists. I.E., this works on a first come,
  82. * first served basis.
  83. *
  84. * We also do NOT allow child windows to be shell windows. Other than that,
  85. * it's up to the caller to size the window appropriately.
  86. *
  87. * The pwndBkGnd is provided for the explorer shell. Since the shellwnd and
  88. * the window which does the drawing of background wallpapers are different,
  89. * we need to provide means by which we can draw directly on the background
  90. * window during hung-app drawing. The pwnd and pwndBkGnd will be identical
  91. * if called through the SetShellWindow() api.
  92. \***************************************************************************/
  93. BOOL xxxSetShellWindow(
  94. PWND pwnd,
  95. PWND pwndBkGnd)
  96. {
  97. PTHREADINFO ptiCurrent = PtiCurrent();
  98. PDESKTOPINFO pdeskinfo = GETDESKINFO(ptiCurrent);
  99. PPROCESSINFO ppiShellProcess;
  100. UserAssert(pwnd);
  101. /*
  102. * Fail the call if another shell window exists.
  103. */
  104. if (pdeskinfo->spwndShell != NULL) {
  105. RIPERR0(ERROR_ACCESS_DENIED,
  106. RIP_WARNING,
  107. "A shellwindow has already been set");
  108. return FALSE;
  109. }
  110. /*
  111. * The shell window must be
  112. * (1) Top-level
  113. * (2) Unowned
  114. * (3) Not topmost
  115. */
  116. if (TestwndChild(pwnd) ||
  117. pwnd->spwndOwner != NULL ||
  118. TestWF(pwnd, WEFTOPMOST)) {
  119. RIPERR0(ERROR_INVALID_PARAMETER,
  120. RIP_WARNING,
  121. "xxxSetShellWindow: Invalid type of window");
  122. return FALSE;
  123. }
  124. /*
  125. * Chicago has a totally different input model which has special code
  126. * that checks for Ctrl-Esc and sends it to the shell. We can get
  127. * the same functionality, without totally re-writing our input model
  128. * by just automatically installing the Ctrl-Esc as a hotkey for the
  129. * shell window. The hotkey delivery code has a special case which
  130. * turns this into a WM_SYSCOMMAND message instead of a WM_HOTKEY
  131. * message.
  132. *
  133. * We don't both checking for failure. Somebody could already have
  134. * a Ctrl-Esc handler installed.
  135. */
  136. _RegisterHotKey(pwnd,SC_TASKLIST,MOD_CONTROL,VK_ESCAPE);
  137. /*
  138. * This is the shell window wright.
  139. * So get the process id for the shell.
  140. */
  141. ppiShellProcess = GETPTI(pwnd)->ppi;
  142. /*
  143. * Set the shell process id to the desktop only if it's the first instance
  144. */
  145. if ((ppiShellProcess != NULL) && (pdeskinfo->ppiShellProcess == NULL)) {
  146. pdeskinfo->ppiShellProcess = ppiShellProcess;
  147. }
  148. Lock(&pdeskinfo->spwndShell, pwnd);
  149. Lock(&pdeskinfo->spwndBkGnd, pwndBkGnd);
  150. /*
  151. * Push window to bottom of stack.
  152. */
  153. SetWF(pdeskinfo->spwndShell, WFBOTTOMMOST);
  154. xxxSetWindowPos(pdeskinfo->spwndShell,
  155. PWND_BOTTOM,
  156. 0,
  157. 0,
  158. 0,
  159. 0,
  160. SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
  161. return TRUE;
  162. }
  163. /***************************************************************************\
  164. * _InitPwSB
  165. *
  166. * History:
  167. * 10-23-90 MikeHar Ported from WaWaWaWindows.
  168. * 11-28-90 JimA Changed to int *
  169. * 01-21-91 IanJa Prefix '_' denoting exported function (although not API)
  170. \***************************************************************************/
  171. PSBINFO _InitPwSB(
  172. PWND pwnd)
  173. {
  174. if (pwnd->pSBInfo) {
  175. /*
  176. * If memory is already allocated, don't bother to do it again.
  177. */
  178. return pwnd->pSBInfo;
  179. }
  180. pwnd->pSBInfo = (PSBINFO)DesktopAlloc(pwnd->head.rpdesk,
  181. sizeof(SBINFO),
  182. DTAG_SBINFO);
  183. if (pwnd->pSBInfo != NULL) {
  184. pwnd->pSBInfo->Vert.posMax = 100;
  185. pwnd->pSBInfo->Horz.posMax = 100;
  186. }
  187. return pwnd->pSBInfo;
  188. }