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.

203 lines
5.5 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: Main.cpp
  3. *
  4. * This file contains the code to support the functionality test harness
  5. * for GDI+. This includes menu options and calling the appropriate
  6. * functions for execution.
  7. *
  8. * Created: 28-Apr-2000 - Jeff Vezina [t-jfvez]
  9. *
  10. * Copyright (c) 2000 Microsoft Corporation
  11. *
  12. \**************************************************************************/
  13. #undef UNICODE
  14. #undef _UNICODE
  15. #include <windows.h>
  16. #include <commctrl.h>
  17. #include "CFuncTest.h"
  18. #include "resource.h"
  19. CFuncTest g_FuncTest; // FuncTest (handles test runs)
  20. HBRUSH g_hbrBackground=NULL; // Main window background color
  21. HWND g_hWndMain=NULL; // Main window
  22. int g_nResult=0; // Result of test run
  23. int gnPaths = 2;
  24. // Include all the outputs (classes derived from COutput)
  25. #include "CHWND.h"
  26. #include "CHDC.h"
  27. #include "CPrinter.h"
  28. // Include all the primitives (classes derived from CPrimitive)
  29. #include "CPaths.h"
  30. #include "CBanding.h"
  31. #include "CExtra.h"
  32. // Create global objects for each individual output
  33. // First constructor param is the regression flag
  34. // If true, the test will take part of the regression suite
  35. CHWND g_HWND(true);
  36. CHDC g_HDC(true);
  37. CPrinter g_Printer(false);
  38. LPFNGDIPLUS glpfnDisplayPaletteWindowNotify;
  39. // Create global objects for each individual setting
  40. // First constructor param is the regression flag
  41. // If true, the test will take part of the regression suite
  42. LRESULT CALLBACK WndProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
  43. // Main window proc
  44. {
  45. switch (Msg)
  46. {
  47. case WM_COMMAND: // Process menu buttons
  48. switch(LOWORD(wParam))
  49. {
  50. case IDM_RUN:
  51. g_FuncTest.Run();
  52. break;
  53. case IDM_SAMPLES:
  54. g_FuncTest.RunSamples();
  55. break;
  56. case IDM_QUIT:
  57. exit(0);
  58. break;
  59. }
  60. break;
  61. case WM_DESTROY:
  62. PostQuitMessage(0);
  63. break;
  64. }
  65. return DefWindowProcA(hWnd,Msg,wParam,lParam);
  66. }
  67. void WindowUninit()
  68. // Uninitializes window
  69. {
  70. if (g_hbrBackground!=NULL) // Destroy background brush
  71. {
  72. DeleteObject((HGDIOBJ)g_hbrBackground);
  73. g_hbrBackground=NULL;
  74. }
  75. if (g_hWndMain!=NULL) // Destroy main window
  76. {
  77. DestroyWindow(g_hWndMain);
  78. g_hWndMain=NULL;
  79. }
  80. }
  81. BOOL WindowInit()
  82. // Creates window and starts up app
  83. {
  84. WNDCLASSA wc;
  85. HINSTANCE hInst=GetModuleHandleA(NULL);
  86. // Create white background brush
  87. g_hbrBackground=CreateSolidBrush(RGB(0xFF,0xFF,0xFF));
  88. wc.style = CS_HREDRAW | CS_VREDRAW;
  89. wc.lpfnWndProc = WndProc;
  90. wc.cbClsExtra = 0;
  91. wc.cbWndExtra = 0;
  92. wc.hInstance = hInst;
  93. wc.hIcon = LoadIconA(NULL,MAKEINTRESOURCEA(32512));// IDI_APPLICATION);
  94. wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
  95. wc.hbrBackground = g_hbrBackground;
  96. wc.lpszMenuName = MAKEINTRESOURCEA(IDR_MENU1);
  97. wc.lpszClassName = "DriverHack";
  98. if (!RegisterClassA(&wc))
  99. return false;
  100. g_hWndMain=CreateWindowExA(
  101. 0,
  102. "DriverHack",
  103. "GDI+ Functionality Test",
  104. WS_OVERLAPPED|WS_CAPTION|WS_BORDER|WS_THICKFRAME|WS_MAXIMIZEBOX|
  105. WS_MINIMIZEBOX|WS_CLIPCHILDREN|WS_VISIBLE|WS_MAXIMIZE|WS_SYSMENU,
  106. CW_USEDEFAULT,
  107. CW_USEDEFAULT,
  108. CW_USEDEFAULT,
  109. CW_USEDEFAULT,
  110. NULL,
  111. NULL,
  112. hInst,
  113. NULL
  114. );
  115. HRESULT h=GetLastError();
  116. if (g_hWndMain==NULL)
  117. return false;
  118. ShowWindow(g_hWndMain,SW_SHOW);
  119. UpdateWindow(g_hWndMain);
  120. return true;
  121. }
  122. /***************************************************************************\
  123. * main(argc, argv[])
  124. *
  125. * Sets up the message loop.
  126. *
  127. * History:
  128. * 04-07-91 - Created - KentD
  129. * 04-28-00 - Modified - Jeff Vezina (t-jfvez)
  130. *
  131. \***************************************************************************/
  132. __cdecl main(int argc,PCHAR argv[])
  133. {
  134. MSG msg;
  135. HMODULE hmodGdiPlus;
  136. CoInitialize(NULL);
  137. if (!WindowInit())
  138. return 0;
  139. if (!g_FuncTest.Init(g_hWndMain))
  140. return 0;
  141. hmodGdiPlus = LoadLibrary(TEXT("gdiplus.dll"));
  142. if(hmodGdiPlus) {
  143. glpfnDisplayPaletteWindowNotify = (LPFNGDIPLUS)
  144. GetProcAddress(hmodGdiPlus,
  145. TEXT("GdipDisplayPaletteWindowNotify"));
  146. }
  147. if((glpfnDisplayPaletteWindowNotify == NULL) || (hmodGdiPlus == NULL)) {
  148. MessageBox(NULL,
  149. "Unable to load gdiplus.dll",
  150. "CfuncTest",
  151. MB_OK);
  152. return FALSE;
  153. }
  154. // Init all primitives, graphics types, and graphics settings
  155. g_HWND.Init();
  156. g_HDC.Init();
  157. g_Printer.Init();
  158. // Put initializations into cextra.cpp, so that individual
  159. // developers can implement their own file for private usage.
  160. ExtraInitializations();
  161. while (GetMessageA(&msg,NULL,0,0)) {
  162. TranslateMessage(&msg);
  163. DispatchMessageA(&msg);
  164. }
  165. WindowUninit();
  166. FreeLibrary(hmodGdiPlus);
  167. CoUninitialize();
  168. return g_nResult;
  169. }
  170. #define UNICODE
  171. #define _UNICODE