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.

90 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. return COutput::Init();
  26. }
  27. Graphics *CPrinter::PreDraw(int &nOffsetX,int &nOffsetY)
  28. {
  29. Graphics *g=NULL;
  30. PRINTDLGA pd =
  31. {
  32. sizeof(PRINTDLG),
  33. NULL, // hwndOwner
  34. NULL, // hDevMode
  35. NULL, // hDevNames
  36. NULL, // hDC
  37. PD_RETURNDC,
  38. 1,
  39. 1,
  40. 1,
  41. 1,
  42. 1,
  43. GetModuleHandleA(NULL),
  44. NULL,
  45. NULL, // print hook
  46. NULL, // setup hook
  47. NULL, // print template name
  48. NULL, // setup template name
  49. NULL, // hPrintTemplate
  50. NULL // hSetupTemplate
  51. };
  52. if (!PrintDlgA(&pd))
  53. {
  54. MessageBoxA(NULL, "No printer selected.", NULL, MB_OK);
  55. return NULL;
  56. }
  57. DOCINFOA docinfo;
  58. docinfo.cbSize = sizeof(DOCINFO);
  59. docinfo.lpszDocName = "GDI+ Print Test";
  60. docinfo.lpszOutput = NULL; // put name here to output to file
  61. docinfo.lpszDatatype = NULL; // data type 'emf' or 'raw'
  62. docinfo.fwType = 0;
  63. m_hDC = pd.hDC;
  64. INT printJobID = StartDocA(m_hDC, &docinfo);
  65. StartPage(m_hDC);
  66. SetStretchBltMode(m_hDC, HALFTONE);
  67. SetBrushOrgEx(m_hDC, 0, 0, NULL);
  68. g = Graphics::FromHDC(m_hDC);
  69. return g;
  70. }
  71. void CPrinter::PostDraw(RECT rTestArea)
  72. {
  73. EndPage(m_hDC);
  74. EndDoc(m_hDC);
  75. DeleteDC(m_hDC);
  76. MessageBoxA(NULL, "Print Functionality Test Complete.", NULL, MB_OK);
  77. }