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.

140 lines
4.1 KiB

  1. /*** mhwin - Help Windowing Code
  2. *
  3. * Copyright <C> 1988, Microsoft Corporation
  4. *
  5. * This module contains routines dealing with opening and closing the help
  6. * display window.
  7. *
  8. * Revision History (most recent first):
  9. *
  10. * [] 12-Mar-1989 LN Split off of mhdisp.c
  11. *
  12. *************************************************************************/
  13. #include <string.h> /* string functions */
  14. #include "mh.h" /* help extension include file */
  15. /*** OpenWin - Open a window on the help file, empty & make current.
  16. *
  17. * Entry:
  18. * cLines = Desired size of window.
  19. *
  20. * Exit:
  21. * Returns help file PWND
  22. *
  23. *************************************************************************/
  24. PWND pascal near OpenWin (
  25. ushort cLines
  26. ) {
  27. PWND pWinCur; /* win handle for current win */
  28. winContents wc; /* description of win contents */
  29. int winSize; /* size of current window */
  30. fInOpen = TRUE;
  31. /*
  32. ** Get a handle to the current window, and a handle to the help window if up.
  33. ** If they are NOT the same, then save the "current" handle as the one the
  34. ** user had active prior to asking for help.
  35. */
  36. GetEditorObject (RQ_WIN_HANDLE, 0, &pWinCur);
  37. pWinHelp = FindHelpWin (FALSE);
  38. if (pWinHelp != pWinCur)
  39. pWinUser = pWinCur;
  40. /*
  41. ** If no help window was found. Attempt to split the current window, if
  42. ** it's big enough, and that's requested
  43. */
  44. if (!pWinHelp) {
  45. GetEditorObject (RQ_WIN_CONTENTS | 0xff, pWinUser, &wc);
  46. #if defined(PWB)
  47. /*
  48. ** In PWB we just ask the editor to split the current window in half.
  49. */
  50. fSplit = FALSE;
  51. if ((wc.arcWin.ayBottom - wc.arcWin.ayTop >= 12) && fCreateWindow) {
  52. fSplit = SplitWnd (pWinUser, FALSE, (wc.arcWin.ayBottom - wc.arcWin.ayTop)/2);
  53. GetEditorObject (RQ_WIN_HANDLE, 0, &pWinHelp);
  54. }
  55. }
  56. /*
  57. ** We have a window, of some sort, attempt to resize the window to the
  58. ** requested size.
  59. */
  60. if (cLines) {
  61. cLines += 2;
  62. GetEditorObject (RQ_WIN_CONTENTS | 0xff, pWinHelp, &wc);
  63. wc.arcWin.ayBottom = wc.arcWin.ayTop + cLines;
  64. Resize (pWinHelp, wc.arcWin);
  65. }
  66. #else
  67. /*
  68. ** Non PWB: Attempt to split the resulting current window to the desired size.
  69. ** by moving the cursor there, and executing arg window. Note that if the
  70. ** window had already existed, we won't even try to resize.
  71. */
  72. winSize = wc.arcWin.ayBottom - wc.arcWin.ayTop;
  73. if ( (cLines < 6)
  74. || (cLines > (ushort)(winSize - 6)))
  75. cLines = (ushort)(winSize / 2);
  76. if ((cLines > 6) && fCreateWindow) {
  77. fSplit = SplitWnd(pWinUser, FALSE, (LINE)cLines);
  78. //fSplit = SplitWnd(pWinUser, FALSE, wc.flPos.lin + (long)cLines);
  79. // rjsa MoveCur (wc.flPos.col, wc.flPos.lin + (long)cLines);
  80. // rjsa fSplit = fExecute ("arg window");
  81. GetEditorObject (RQ_WIN_HANDLE, 0, &pWinHelp);
  82. }
  83. else
  84. pWinHelp = pWinUser;
  85. }
  86. #endif
  87. /*
  88. ** Set the window to be the current window, and move the help file to the
  89. ** top of that window's file list.
  90. */
  91. SetEditorObject (RQ_WIN_CUR | 0xff, pWinHelp, 0);
  92. DelFile (pHelp);
  93. asserte (pFileToTop (pHelp));
  94. fInOpen = FALSE;
  95. return pWinHelp;
  96. /* end OpenWin */}
  97. /*** FindHelpWin - Locate window containing help & make current
  98. *
  99. * For all windows in the system, look for a window that has the help file
  100. * in it. If found, set focus there.
  101. *
  102. * Entry:
  103. * fSetCur = TRUE=> set help window current when found
  104. *
  105. * Globals:
  106. * cWinSystem = returned number of windows in system
  107. *
  108. * Returns:
  109. * pWin of help file
  110. *
  111. *************************************************************************/
  112. PWND pascal near FindHelpWin (
  113. flagType fSetCur
  114. ) {
  115. int cWinSystem; /* number of windows in system */
  116. winContents wc; /* description of win contents */
  117. pWinHelp = 0;
  118. for (cWinSystem=1; cWinSystem<=8; cWinSystem++) {
  119. if (GetEditorObject (RQ_WIN_CONTENTS | cWinSystem, 0, &wc)) {
  120. if (wc.pFile == pHelp) {
  121. if (fSetCur) {
  122. SetEditorObject (RQ_WIN_CUR | cWinSystem, 0, 0);
  123. GetEditorObject (RQ_WIN_HANDLE, 0, &pWinHelp);
  124. }
  125. else
  126. GetEditorObject (RQ_WIN_HANDLE | cWinSystem, 0, &pWinHelp);
  127. break;
  128. }
  129. }
  130. else
  131. break;
  132. }
  133. return pWinHelp;
  134. /* end FindHelpWin */}