Source code of Windows XP (NT5)
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.

282 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. ShowPerf.c
  5. Abstract:
  6. Provides a GUI interface to display the contents of a perf data
  7. block
  8. Author:
  9. Bob Watson (a-robw)
  10. Revision History:
  11. 23 Nov 94
  12. --*/
  13. #include <windows.h>
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. #include "showperf.h"
  17. #include "resource.h"
  18. #include "mainwnd.h"
  19. #include "maindlg.h"
  20. #define NUM_BUFS 4
  21. // variable definition
  22. static WORD wHelpContextId = IDH_CONTENTS;
  23. LPCTSTR
  24. GetStringResource (
  25. IN HANDLE hInstance,
  26. IN UINT nId
  27. )
  28. /*++
  29. Routine Description:
  30. look up string resource and return string
  31. Arguments:
  32. IN UINT nId
  33. Resource ID of string to look up
  34. Return Value:
  35. pointer to string referenced by ID in arg list
  36. --*/
  37. {
  38. static TCHAR szBufArray[NUM_BUFS][SMALL_BUFFER_SIZE];
  39. static DWORD dwIndex;
  40. LPTSTR szBuffer;
  41. DWORD dwLength;
  42. HANDLE hMod;
  43. if (hInstance != NULL) {
  44. hMod = hInstance;
  45. } else {
  46. hMod = GetModuleHandle(NULL);
  47. }
  48. dwIndex++;
  49. dwIndex %= NUM_BUFS;
  50. szBuffer = &szBufArray[dwIndex][0];
  51. // clear previous contents
  52. memset (szBuffer, 0, (SMALL_BUFFER_SIZE * sizeof(TCHAR)));
  53. dwLength = LoadString (
  54. hMod,
  55. nId,
  56. szBuffer,
  57. SMALL_BUFFER_SIZE);
  58. return (LPCTSTR)szBuffer;
  59. }
  60. VOID
  61. SetHelpContextId (
  62. WORD wId
  63. )
  64. {
  65. wHelpContextId = wId;
  66. return;
  67. }
  68. WORD
  69. GetHelpContextId (
  70. )
  71. {
  72. return wHelpContextId;
  73. }
  74. int
  75. DisplayMessageBox (
  76. IN HWND hWnd,
  77. IN UINT nMessageId,
  78. IN UINT nTitleId,
  79. IN UINT nStyle
  80. )
  81. /*++
  82. Routine Description:
  83. Displays a message box displaying text from the resource file, as
  84. opposed to literal strings.
  85. Arguments:
  86. IN HWND hWnd window handle to parent window
  87. IN UINT nMessageId String Resource ID of message text to display
  88. IN UINT nTitleId String Resource ID of title text to display
  89. IN UINT nStyle MB style bits (see MessageBox function)
  90. Return Value:
  91. ID of button pressed to exit message box
  92. --*/
  93. {
  94. LPTSTR szMessageText = NULL;
  95. LPTSTR szTitleText = NULL;
  96. HINSTANCE hInst;
  97. int nReturn;
  98. hInst = GET_INSTANCE(hWnd);
  99. szMessageText = GLOBAL_ALLOC (SMALL_BUFFER_BYTES);
  100. szTitleText = GLOBAL_ALLOC (SMALL_BUFFER_BYTES);
  101. if ((szMessageText != NULL) &&
  102. (szTitleText != NULL)) {
  103. LoadString (hInst,
  104. ((nTitleId != 0) ? nTitleId : IDS_APP_TITLE),
  105. szTitleText,
  106. SMALL_BUFFER_SIZE -1);
  107. LoadString (hInst,
  108. nMessageId,
  109. szMessageText,
  110. SMALL_BUFFER_SIZE - 1);
  111. nReturn = MessageBox (
  112. hWnd,
  113. szMessageText,
  114. szTitleText,
  115. nStyle);
  116. } else {
  117. nReturn = IDCANCEL;
  118. }
  119. GLOBAL_FREE_IF_ALLOC (szMessageText);
  120. GLOBAL_FREE_IF_ALLOC (szTitleText);
  121. return nReturn;
  122. }
  123. BOOL
  124. UpdateSystemMenu (
  125. IN HWND hWnd // window handle
  126. )
  127. /*++
  128. Routine Description:
  129. modifies the system menu by:
  130. Removing the "Restore", "Size", "Minimize" and "Maximize" entries
  131. Arguments:
  132. IN HWND hWnd
  133. window handle of window containing the system menu to modify
  134. Return Value:
  135. TRUE if successfully made changes, otherwise
  136. FALSE if error occurred
  137. --*/
  138. {
  139. UNREFERENCED_PARAMETER (hWnd);
  140. return TRUE;
  141. }
  142. BOOL
  143. ShowAppHelp (
  144. IN HWND hWnd
  145. )
  146. /*++
  147. Routine Description:
  148. Generic routine to call WinHelp engine for displaying application
  149. help. wContext parameter is used for context.
  150. Arguments:
  151. IN HWND hWnd
  152. window handle of calling window
  153. Return Value:
  154. TRUE if help called successfully
  155. --*/
  156. {
  157. return WinHelp (hWnd,
  158. GetStringResource(GET_INSTANCE(hWnd), IDS_HELP_FILENAME),
  159. HELP_CONTEXT,
  160. (DWORD)GetHelpContextId());
  161. }
  162. int APIENTRY
  163. WinMain(
  164. IN HINSTANCE hInstance,
  165. IN HINSTANCE hPrevInstance,
  166. IN LPSTR szCmdLine,
  167. IN int nCmdShow
  168. )
  169. /*++
  170. Routine Description:
  171. Program entry point for LoadAccount application. Initializes Windows
  172. data structures and begins windows message processing loop.
  173. Arguments:
  174. Standard WinMain arguments
  175. ReturnValue:
  176. 0 if unable to initialize correctly, or
  177. wParam from WM_QUIT message if messages processed
  178. --*/
  179. {
  180. HWND hWnd; // Main window handle.
  181. MSG msg;
  182. UNREFERENCED_PARAMETER (nCmdShow);
  183. UNREFERENCED_PARAMETER (szCmdLine);
  184. UNREFERENCED_PARAMETER (hPrevInstance);
  185. if (RegisterMainWindowClass(hInstance)) {
  186. hWnd = CreateMainWindow (hInstance);
  187. if (hWnd != NULL) {
  188. // Acquire and dispatch messages until a
  189. // WM_QUIT message is received.
  190. while (GetMessage(&msg, // message structure
  191. NULL, // handle of window receiving the message
  192. 0, // lowest message to examine
  193. 0)) // highest message to examine
  194. {
  195. // process this message
  196. TranslateMessage(&msg);// Translates virtual key codes
  197. DispatchMessage(&msg); // Dispatches message to window
  198. }
  199. return (int)(msg.wParam); // Returns the value from PostQuitMessage
  200. } else {
  201. return (ERROR_CAN_NOT_COMPLETE);
  202. }
  203. } else {
  204. return (ERROR_CAN_NOT_COMPLETE);
  205. }
  206. }