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.

125 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. mainwnd.c
  5. Abstract:
  6. Main Window procedure for ShowPerf app
  7. Author:
  8. Bob Watson (a-robw)
  9. Revision History:
  10. 23 Nov 94
  11. --*/
  12. #include <windows.h>
  13. #include "resource.h"
  14. #include "SHOWPERF.h"
  15. //
  16. // GLOBAL functions
  17. //
  18. LRESULT CALLBACK
  19. MainWndProc(
  20. HWND hWnd, // window handle
  21. UINT message, // type of message
  22. WPARAM wParam, // additional information
  23. LPARAM lParam // additional information
  24. )
  25. /*++
  26. Routine Description:
  27. Windows Message processing routine for restkeys application.
  28. Arguments:
  29. Standard WNDPROC api arguments
  30. ReturnValue:
  31. 0 or
  32. value returned by DefWindowProc
  33. --*/
  34. {
  35. LRESULT lResult = ERROR_SUCCESS;
  36. switch (message) {
  37. case WM_CLOSE:
  38. DestroyWindow(hWnd);
  39. break;
  40. case WM_DESTROY:
  41. PostQuitMessage(ERROR_SUCCESS);
  42. break;
  43. default:
  44. lResult = DefWindowProc(hWnd, message, wParam, lParam);
  45. break;
  46. }
  47. return lResult;
  48. }
  49. BOOL
  50. RegisterMainWindowClass(
  51. HINSTANCE hInstance
  52. )
  53. /*++
  54. Routine Description:
  55. Registers the main window class for this application
  56. Arguments:
  57. hInstance application instance handle
  58. Return Value:
  59. Return value of RegisterClass function
  60. --*/
  61. {
  62. WNDCLASSW wc;
  63. // Fill in window class structure with parameters that describe the
  64. // main window.
  65. wc.style = CS_HREDRAW | CS_VREDRAW; // Class style(s).
  66. wc.lpfnWndProc = MainWndProc; // Window Procedure
  67. wc.cbClsExtra = 0; // No per-class extra data.
  68. wc.cbWndExtra = 0; // no extra data bytes.
  69. wc.hInstance = hInstance; // Owner of this class
  70. wc.hIcon = NULL; // No Icon
  71. wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Cursor
  72. wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); // Default color
  73. wc.lpszMenuName = NULL; // No Menu
  74. wc.lpszClassName = GetStringResource(hInstance, IDS_APP_WINDOW_CLASS); // Name to register as
  75. // Register the window class and return success/failure code.
  76. return (BOOL) RegisterClassW(& wc);
  77. }
  78. HWND
  79. CreateMainWindow(
  80. HINSTANCE hInstance
  81. )
  82. {
  83. HWND hWnd; // return value
  84. RECT rDesktop; // desktop window
  85. GetWindowRect(GetDesktopWindow(), & rDesktop);
  86. // Create a main window for this application instance.
  87. hWnd = CreateWindowExW(
  88. 0L, // make this window normal so debugger isn't covered
  89. GetStringResource(hInstance, IDS_APP_WINDOW_CLASS), // See RegisterClass() call.
  90. GetStringResource(hInstance, IDS_APP_TITLE), // Text for window title bar.
  91. (DWORD) (WS_OVERLAPPEDWINDOW), // Window style.
  92. rDesktop.right + 1, // position window off desktop
  93. rDesktop.bottom + 1,
  94. 1,
  95. 1,
  96. (HWND) NULL, // Overlapped windows have no parent.
  97. (HMENU) NULL, // use class menu
  98. hInstance, // This instance owns this window.
  99. NULL // not used
  100. );
  101. // If window could not be created, return "failure"
  102. if (hWnd != NULL) {
  103. DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), hWnd, MainDlgProc);
  104. PostMessage(hWnd, WM_CLOSE, 0, 0); // pack up and leave
  105. }
  106. return hWnd;
  107. }