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.

186 lines
4.7 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // File: wterm2.cxx
  4. //
  5. // Contents: Shared Windows Procedures
  6. //
  7. // Classes: none
  8. //
  9. // History: 23-Nov-92 Rickhi Created
  10. //
  11. //--------------------------------------------------------------------
  12. #include <pch.cxx>
  13. #pragma hdrstop
  14. extern "C"
  15. {
  16. #include "wterm.h"
  17. #include <memory.h>
  18. #include <stdio.h>
  19. }
  20. // function prototypes
  21. long ProcessMenu(HWND hWindow, UINT uiMessage, WPARAM wParam, LPARAM lParam,
  22. void *);
  23. long ProcessChar(HWND hWindow, UINT uiMessage, WPARAM wParam, LPARAM lParam,
  24. void *);
  25. long ProcessClose(
  26. HWND hWindow,
  27. UINT uiMessage,
  28. WPARAM wParam,
  29. LPARAM lParam,
  30. void *pvCallBackData);
  31. #define IDM_DEBUG 0x100
  32. // global variables.
  33. HWND g_hMain;
  34. #if DBG==1
  35. BOOL g_fDisplay = 1;
  36. #else
  37. BOOL g_fDisplay = 0;
  38. #endif
  39. //+-------------------------------------------------------------------------
  40. //
  41. // Function: Display
  42. //
  43. // Synopsis: prints a message on the window
  44. //
  45. // History: 06-Aug-92 Ricksa Created
  46. //
  47. //--------------------------------------------------------------------------
  48. void Display(TCHAR *pszFmt, ...)
  49. {
  50. // since it takes a long time to display these messages and we dont
  51. // want to skew benchmarks, displaying the messages is optional.
  52. // the messages are usefull for debugging.
  53. if (!g_fDisplay)
  54. return;
  55. va_list marker;
  56. TCHAR szBuffer[256];
  57. va_start(marker, pszFmt);
  58. #ifdef UNICODE
  59. int iLen = vswprintf(szBuffer, pszFmt, marker);
  60. #else
  61. int iLen = vsprintf(szBuffer, pszFmt, marker);
  62. #endif
  63. va_end(marker);
  64. // Display the message on terminal window
  65. SendMessage(g_hMain, WM_PRINT_LINE, iLen, (LONG) szBuffer);
  66. }
  67. //+-------------------------------------------------------------------------
  68. //
  69. // Function: ProcessMenu
  70. //
  71. // Synopsis: Gets called when a WM_COMMAND message received.
  72. //
  73. // Arguments: [hWindow] - handle for the window
  74. // [uiMessage] - message id
  75. // [wParam] - word parameter
  76. // [lParam] - long parameter
  77. //
  78. // Returns: DefWindowProc result
  79. //
  80. // History: 06-Aug-92 Ricksa Created
  81. //
  82. //--------------------------------------------------------------------------
  83. long ProcessMenu(HWND hWindow, UINT uiMessage, WPARAM wParam, LPARAM lParam,
  84. void *)
  85. {
  86. return (DefWindowProc(hWindow, uiMessage, wParam, lParam));
  87. }
  88. //+-------------------------------------------------------------------------
  89. //
  90. // Function: ProcessChar
  91. //
  92. // Synopsis: Gets called when a WM_CHAR message received.
  93. //
  94. // Arguments: [hWindow] - handle for the window
  95. // [uiMessage] - message id
  96. // [wParam] - word parameter
  97. // [lParam] - long parameter
  98. //
  99. // Returns: DefWindowProc result
  100. //
  101. // History: 06-Aug-92 Ricksa Created
  102. //
  103. //--------------------------------------------------------------------------
  104. long ProcessChar(HWND hWindow, UINT uiMessage, WPARAM wParam, LPARAM lParam,
  105. void *)
  106. {
  107. return (DefWindowProc(hWindow, uiMessage, wParam, lParam));
  108. }
  109. //+-------------------------------------------------------------------------
  110. //
  111. // Function: ProcessClose
  112. //
  113. // Synopsis: Gets called when a NC_DESTROY message received.
  114. //
  115. // Arguments: [hWindow] - handle for the window
  116. // [uiMessage] - message id
  117. // [wParam] - word parameter
  118. // [lParam] - long parameter
  119. //
  120. // Returns: DefWindowProc result
  121. //
  122. // History: 06-Aug-92 Ricksa Created
  123. //
  124. //--------------------------------------------------------------------------
  125. long ProcessClose(
  126. HWND hWindow,
  127. UINT uiMessage,
  128. WPARAM wParam,
  129. LPARAM lParam,
  130. void *pvCallBackData)
  131. {
  132. // Take default action with message
  133. return (DefWindowProc(hWindow, uiMessage, wParam, lParam));
  134. }
  135. //+-------------------------------------------------------------------------
  136. //
  137. // Function: MakeTheWindow
  138. //
  139. // Synopsis: Creates the terminal window.
  140. //
  141. // Arguments: [hInstance] -
  142. // [pwszAppName] - app name to display
  143. //
  144. // History: 06-Aug-92 Ricksa Created
  145. //
  146. //--------------------------------------------------------------------------
  147. void MakeTheWindow(HANDLE hInstance, TCHAR *pwszAppName)
  148. {
  149. // Register the window class
  150. TermRegisterClass(hInstance, (LPTSTR) pwszAppName,
  151. (LPTSTR) pwszAppName, (LPTSTR) (1));
  152. // Create the server window
  153. TermCreateWindow(
  154. (LPTSTR) pwszAppName,
  155. (LPTSTR) pwszAppName,
  156. NULL,
  157. ProcessMenu,
  158. ProcessChar,
  159. ProcessClose,
  160. SW_SHOWMINIMIZED,
  161. (HWND *)&g_hMain,
  162. NULL);
  163. // Add debug option to system menu
  164. HMENU hmenu = GetSystemMenu(g_hMain, FALSE);
  165. AppendMenu(hmenu, MF_SEPARATOR, 0, NULL);
  166. AppendMenu(hmenu, MF_STRING | MF_ENABLED, IDM_DEBUG, TEXT("Debug"));
  167. }