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.

93 lines
2.2 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: CPrinter.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: 05-May-2000 - Jeff Vezina [t-jfvez]
  9. *
  10. * Copyright (c) 2000 Microsoft Corporation
  11. *
  12. \**************************************************************************/
  13. #include "CPrinter.h"
  14. CPrinter::CPrinter(BOOL bRegression)
  15. {
  16. m_hDC=NULL;
  17. strcpy(m_szName,"Printer");
  18. m_bRegression=bRegression;
  19. }
  20. CPrinter::~CPrinter()
  21. {
  22. }
  23. BOOL CPrinter::Init()
  24. {
  25. // hidden API to turn on our printing code
  26. DllExports::GdipDisplayPaletteWindowNotify((WindowNotifyEnum)0xFFFFFFFF);
  27. return COutput::Init();
  28. }
  29. Graphics *CPrinter::PreDraw(int &nOffsetX,int &nOffsetY)
  30. {
  31. Graphics *g=NULL;
  32. PRINTDLGA pd =
  33. {
  34. sizeof(PRINTDLG),
  35. NULL, // hwndOwner
  36. NULL, // hDevMode
  37. NULL, // hDevNames
  38. NULL, // hDC
  39. PD_RETURNDC,
  40. 1,
  41. 1,
  42. 1,
  43. 1,
  44. 1,
  45. GetModuleHandleA(NULL),
  46. NULL,
  47. NULL, // print hook
  48. NULL, // setup hook
  49. NULL, // print template name
  50. NULL, // setup template name
  51. NULL, // hPrintTemplate
  52. NULL // hSetupTemplate
  53. };
  54. if (!PrintDlgA(&pd))
  55. {
  56. MessageBoxA(NULL, "No printer selected.", NULL, MB_OK);
  57. return NULL;
  58. }
  59. DOCINFOA docinfo;
  60. docinfo.cbSize = sizeof(DOCINFO);
  61. docinfo.lpszDocName = "GDI+ Print Test";
  62. docinfo.lpszOutput = NULL; // put name here to output to file
  63. docinfo.lpszDatatype = NULL; // data type 'emf' or 'raw'
  64. docinfo.fwType = 0;
  65. m_hDC = pd.hDC;
  66. INT printJobID = StartDocA(m_hDC, &docinfo);
  67. StartPage(m_hDC);
  68. SetStretchBltMode(m_hDC, HALFTONE);
  69. SetBrushOrgEx(m_hDC, 0, 0, NULL);
  70. g = Graphics::FromHDC(m_hDC);
  71. return g;
  72. }
  73. void CPrinter::PostDraw(RECT rTestArea)
  74. {
  75. EndPage(m_hDC);
  76. EndDoc(m_hDC);
  77. DeleteDC(m_hDC);
  78. MessageBoxA(NULL, "Print Functionality Test Complete.", NULL, MB_OK);
  79. }