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.

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