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.

159 lines
3.5 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: wndstuff.c
  3. *
  4. * This file contains the code to support a simple window that has
  5. * a menu with a single item called "Test". When "Test" is selected
  6. * vTest(HWND) is called.
  7. *
  8. * Created: 09-Dec-1992 10:44:31
  9. * Author: Kirk Olynyk [kirko]
  10. *
  11. * Copyright (c) 1991 Microsoft Corporation
  12. *
  13. \**************************************************************************/
  14. #include <nt.h>
  15. #include <ntrtl.h>
  16. #include <nturtl.h>
  17. #include <windows.h>
  18. #include "wndstuff.h"
  19. HANDLE ghInstance;
  20. HWND ghwndMain;
  21. HBRUSH ghbrWhite;
  22. /***************************************************************************\
  23. * main(argc, argv[])
  24. *
  25. * Sets up the message loop.
  26. *
  27. * History:
  28. * 04-07-91 -by- KentD
  29. * Wrote it.
  30. \***************************************************************************/
  31. _cdecl
  32. main(
  33. INT argc,
  34. PCHAR argv[])
  35. {
  36. MSG msg;
  37. HANDLE haccel;
  38. DONTUSE(argc);
  39. DONTUSE(argv);
  40. ghInstance = GetModuleHandle(NULL);
  41. if (!bInitApp())
  42. {
  43. return(0);
  44. }
  45. haccel = LoadAccelerators(ghInstance, MAKEINTRESOURCE(1));
  46. while (GetMessage(&msg, NULL, 0, 0))
  47. {
  48. if (!TranslateAccelerator(msg.hwnd, haccel, &msg))
  49. {
  50. TranslateMessage(&msg);
  51. DispatchMessage(&msg);
  52. }
  53. }
  54. return(1);
  55. }
  56. /***************************************************************************\
  57. * bInitApp()
  58. *
  59. * Initializes app.
  60. *
  61. * History:
  62. * 04-07-91 -by- KentD
  63. * Wrote it.
  64. \***************************************************************************/
  65. BOOL bInitApp(VOID)
  66. {
  67. WNDCLASS wc;
  68. ghbrWhite = CreateSolidBrush(RGB(0xFF,0xFF,0xFF));
  69. wc.style = 0;
  70. wc.lpfnWndProc = lMainWindowProc;
  71. wc.cbClsExtra = 0;
  72. wc.cbWndExtra = 0;
  73. wc.hInstance = ghInstance;
  74. wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  75. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  76. wc.hbrBackground = ghbrWhite;
  77. wc.lpszMenuName = "MainMenu";
  78. wc.lpszClassName = "TestClass";
  79. if (!RegisterClass(&wc))
  80. {
  81. return(FALSE);
  82. }
  83. ghwndMain =
  84. CreateWindowEx(
  85. 0,
  86. "TestClass",
  87. "Win32 Test",
  88. MY_WINDOWSTYLE_FLAGS,
  89. 80,
  90. 70,
  91. 400,
  92. 300,
  93. NULL,
  94. NULL,
  95. ghInstance,
  96. NULL
  97. );
  98. if (ghwndMain == NULL)
  99. {
  100. return(FALSE);
  101. }
  102. SetFocus(ghwndMain);
  103. return(TRUE);
  104. }
  105. /***************************************************************************\
  106. * lMainWindowProc(hwnd, message, wParam, lParam)
  107. *
  108. * Processes all messages for the main window.
  109. *
  110. * History:
  111. * 04-07-91 -by- KentD
  112. * Wrote it.
  113. \***************************************************************************/
  114. BOOL gbOn = FALSE;
  115. POINTL ptlWindow;
  116. SIZEL sizlWindow;
  117. LRESULT
  118. lMainWindowProc(
  119. HWND hwnd,
  120. UINT message,
  121. WPARAM wParam,
  122. LPARAM lParam
  123. )
  124. {
  125. switch (message)
  126. {
  127. case WM_CREATE:
  128. vTest(hwnd);
  129. PostQuitMessage(0);
  130. return(DefWindowProc(hwnd, message, wParam, lParam));
  131. case WM_DESTROY:
  132. DeleteObject(ghbrWhite);
  133. PostQuitMessage(0);
  134. return(DefWindowProc(hwnd, message, wParam, lParam));
  135. default:
  136. return(DefWindowProc(hwnd, message, wParam, lParam));
  137. }
  138. return(0);
  139. }