home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / gdi / printer / printer.h < prev    next >
C/C++ Source or Header  |  1997-10-05  |  9KB  |  255 lines

  1.  
  2. /******************************************************************************\
  3. *       This is a part of the Microsoft Source Code Samples. 
  4. *       Copyright (C) 1993-1997 Microsoft Corporation.
  5. *       All rights reserved. 
  6. *       This source code is only intended as a supplement to 
  7. *       Microsoft Development Tools and/or WinHelp documentation.
  8. *       See these sources for detailed information regarding the 
  9. *       Microsoft samples programs.
  10. \******************************************************************************/
  11.  
  12. /******************************************************************************\
  13. *
  14. *                                PRINTER.H
  15. *
  16. \******************************************************************************/
  17. #include "strings.h"
  18.  
  19.  
  20. /******************************************************************************\
  21. *                             SYMBOLIC CONSTANTS
  22. \******************************************************************************/
  23.  
  24. #define IDM_PRINT                 101  // menu id's
  25. #define IDM_PRINTDLG              102
  26. #define IDM_GETDEVICECAPS         103
  27. #define IDM_ENUMPRINTERS          104
  28. #define IDM_GETPRINTERDRIVER      105
  29. #define IDM_ENUMPRINTERDRIVERS    106
  30. #define IDM_REFRESH               107
  31. #define IDM_ABOUT                 108
  32.  
  33. #define IDM_HIENGLISH             201
  34. #define IDM_HIMETRIC              202
  35. #define IDM_LOENGLISH             203
  36. #define IDM_LOMETRIC              204
  37. #define IDM_TWIPS                 205
  38. #define IDM_ISOTROPIC             206
  39. #define IDM_ANISOTROPIC           207
  40. #define IDM_TEXT                  208
  41.  
  42. #define IDM_ARC                   301
  43. #define IDM_ELLIPSE               302
  44. #define IDM_LINETO                303
  45. #define IDM_PIE                   304
  46. #define IDM_PLGBLT                305
  47. #define IDM_POLYBEZIER            306
  48. #define IDM_POLYGON               307
  49. #define IDM_POLYLINE              308
  50. #define IDM_POLYPOLYGON           309
  51. #define IDM_RECTANGLE             310
  52. #define IDM_ROUNDRECT             311
  53. #define IDM_STRETCHBLT            312
  54. #define IDM_ALLGRAPHICS           313
  55. #define IDM_NOGRAPHICS            314
  56. #define IDM_ENUMFONTS             315
  57. #define IDM_DRAWAXIS              316
  58.  
  59. #define IDM_SETPENCOLOR           401
  60. #define IDM_PENWIDTH_1            402
  61. #define IDM_PENWIDTH_2            403
  62. #define IDM_PENWIDTH_3            404
  63. #define IDM_PENWIDTH_4            405
  64. #define IDM_PENWIDTH_5            406
  65. #define IDM_PENWIDTH_6            407
  66. #define IDM_PENWIDTH_7            408
  67. #define IDM_PENWIDTH_8            409
  68. #define IDM_PENCOLOR_SOLID        410
  69. #define IDM_PENCOLOR_DASH         411
  70. #define IDM_PENCOLOR_DOT          412
  71. #define IDM_PENCOLOR_DASHDOT      413
  72. #define IDM_PENCOLOR_DASHDOTDOT   414
  73. #define IDM_PENCOLOR_NULL         415
  74. #define IDM_PENCOLOR_INSIDEFRAME  416
  75.  
  76. #define IDM_SETBRUSHCOLOR               501
  77. #define IDM_BRUSHSTYLE_HORIZONTAL       502
  78. #define IDM_BRUSHSTYLE_VERTICAL         503
  79. #define IDM_BRUSHSTYLE_FDIAGONAL        504
  80. #define IDM_BRUSHSTYLE_BDIAGONAL        505
  81. #define IDM_BRUSHSTYLE_CROSS            506
  82. #define IDM_BRUSHSTYLE_DIAGCROSS        507
  83. #define IDM_BRUSHSTYLE_SOLIDCLR         508
  84. #define IDM_BRUSHSTYLE_DITHEREDCLR      509
  85. #define IDM_BRUSHSTYLE_SOLIDTEXTCLR     510
  86. #define IDM_BRUSHSTYLE_DITHEREDTEXTCLR  511
  87. #define IDM_BRUSHSTYLE_SOLIDBKCLR       512
  88. #define IDM_BRUSHSTYLE_DITHEREDBKCLR    513
  89.  
  90. #define IDM_TEXTCOLOR             601
  91.  
  92. #define ID_COMBOBOX               701  // toolbar combobox id
  93.  
  94. #define MAIN_ICON                 1
  95. #define MAIN_MENU_NAME            "MENU"
  96. #define MAIN_CLASS_NAME           "PRINTER"
  97. #define MAIN_WND_TITLE              IDS_MAINWNDTITLE
  98. #define MAIN_CLASS_STYLE          CS_HREDRAW | CS_VREDRAW
  99. #define MAIN_WND_STYLE            WS_OVERLAPPEDWINDOW
  100.  
  101. #define MAX_MAP_MODES             8    // # items in gaMMLookup
  102. #define MAX_PENWIDTHS             8    // # items in gaPenWidths
  103. #define MAX_PENSTYLES             7    // # items in gaPenStyles
  104. #define MAX_BRUSHSTYLES           5    // # items in gaBrushStyles
  105.  
  106. #define ERR_MOD_NAME             IDS_ERR_PRINTER
  107.  
  108.  
  109.  
  110. /******************************************************************************\
  111. *                                 TYPEDEFS
  112. \******************************************************************************/
  113.  
  114. typedef struct tagMAPMODELOOKUP
  115. {
  116.   WORD   wMenuItem;
  117.   int    iMapMode;
  118.  
  119. } MAPMODELOOKUP;
  120.  
  121. typedef struct tagGRAPHICLOOKUP
  122. {
  123.   WORD   wMenuItem;
  124.   DWORD  dwGraphic;
  125.  
  126. } GRAPHICLOOKUP;
  127.  
  128. typedef struct tagPENWIDTHLOOKUP
  129. {
  130.   WORD   wMenuItem;
  131.   int    iPenWidth;
  132.  
  133. } PENWIDTHLOOKUP;
  134.  
  135. typedef struct tagPENSTYLELOOKUP
  136. {
  137.   WORD   wMenuItem;
  138.   int    iPenStyle;
  139.  
  140. } PENSTYLELOOKUP;
  141.  
  142. typedef struct tagBRUSHSTYLELOOKUP
  143. {
  144.   WORD   wMenuItem;
  145.   int    iBrushStyle;
  146.  
  147. } BRUSHSTYLELOOKUP;
  148.  
  149. typedef struct tagSTATUSBARLOOKUP
  150. {
  151.   WORD   wMenuItem;
  152.   LPCSTR szText;
  153.  
  154. } STATUSBARLOOKUP;
  155.  
  156.  
  157.  
  158. /******************************************************************************\
  159. *                                GLOBAL VARS
  160. \******************************************************************************/
  161.  
  162. HANDLE  ghInst;                        // app instance handle
  163. HWND    ghwndMain;                     // main app window handle
  164. HWND    ghwndAbort;                    // Abort dialog handle
  165. LONG    glcyMenu;                      // menu height
  166. DWORD   gdwGraphicsOptions = DRAWAXIS; // current graphic options (to display)
  167. int     giMapMode = MM_TEXT;           // current map mode
  168. HDC     ghdc;                          // device context to print on
  169. BOOL    gbAbort;                       // AbortProc return code
  170.  
  171. char    gszDeviceName[BUFSIZE];        // current device name
  172. char    gszPort      [BUFSIZE];        // current port
  173. char    gszDriverName[BUFSIZE];        // current driver name
  174.  
  175. DWORD   gdwPenColor   = 0x00ff00;      // current pen color
  176. DWORD   gdwBrushColor = 0x0000ff;      // current brush color
  177. DWORD   gdwTextColor =  0xff0000;      // current text color
  178.  
  179. int     giPenStyle   = PS_SOLID;       // current pen style
  180. int     giPenWidth   = 1;              // current pen width
  181. int     giBrushStyle = HS_HORIZONTAL;    // current brush style
  182.  
  183. MAPMODELOOKUP gaMMLookup[] =
  184.  
  185.     { { IDM_HIENGLISH  , MM_HIENGLISH   },
  186.       { IDM_HIMETRIC   , MM_HIMETRIC    },
  187.       { IDM_LOENGLISH  , MM_LOENGLISH   },
  188.       { IDM_LOMETRIC   , MM_LOMETRIC    },
  189.       { IDM_TWIPS      , MM_TWIPS       },
  190.       { IDM_ISOTROPIC  , MM_ISOTROPIC   },
  191.       { IDM_ANISOTROPIC, MM_ANISOTROPIC },
  192.       { IDM_TEXT       , MM_TEXT        } };
  193.  
  194. GRAPHICLOOKUP gaGraphicLookup[] =
  195.  
  196.     { { IDM_ARC        , ARC         },
  197.       { IDM_ELLIPSE    , ELLIPSE     },
  198.       { IDM_LINETO     , LINETO      },
  199.       { IDM_PIE        , PIE         },
  200.       { IDM_PLGBLT     , PLG_BLT     },
  201.       { IDM_POLYBEZIER , POLYBEZIER  },
  202.       { IDM_POLYGON    , POLYGON     },
  203.       { IDM_POLYLINE   , POLYLINE    },
  204.       { IDM_POLYPOLYGON, POLYPOLYGON },
  205.       { IDM_RECTANGLE  , RECTANGLE   },
  206.       { IDM_ROUNDRECT  , ROUNDRECT   },
  207.       { IDM_STRETCHBLT , STRETCH_BLT } };
  208.  
  209. PENWIDTHLOOKUP gaPenWidths[] =
  210.  
  211.     { { IDM_PENWIDTH_1, 1 },
  212.       { IDM_PENWIDTH_2, 2 },
  213.       { IDM_PENWIDTH_3, 3 },
  214.       { IDM_PENWIDTH_4, 4 },
  215.       { IDM_PENWIDTH_5, 5 },
  216.       { IDM_PENWIDTH_6, 6 },
  217.       { IDM_PENWIDTH_7, 7 },
  218.       { IDM_PENWIDTH_8, 8 } };
  219.  
  220. PENSTYLELOOKUP gaPenStyles[] =
  221.  
  222.     { { IDM_PENCOLOR_SOLID      , PS_SOLID      },
  223.       { IDM_PENCOLOR_DASH       , PS_DASH       },
  224.       { IDM_PENCOLOR_DOT        , PS_DOT        },
  225.       { IDM_PENCOLOR_DASHDOT    , PS_DASHDOT    },
  226.       { IDM_PENCOLOR_DASHDOTDOT , PS_DASHDOTDOT },
  227.       { IDM_PENCOLOR_NULL       , PS_NULL       },
  228.       { IDM_PENCOLOR_INSIDEFRAME, PS_INSIDEFRAME} };
  229.  
  230. BRUSHSTYLELOOKUP gaBrushStyles[] =
  231.  
  232.     { { IDM_BRUSHSTYLE_HORIZONTAL     , HS_HORIZONTAL     },
  233.       { IDM_BRUSHSTYLE_VERTICAL       , HS_VERTICAL       },
  234.       { IDM_BRUSHSTYLE_FDIAGONAL      , HS_FDIAGONAL      },
  235.       { IDM_BRUSHSTYLE_BDIAGONAL      , HS_BDIAGONAL      },
  236.       { IDM_BRUSHSTYLE_CROSS          , HS_CROSS          },
  237.       { IDM_BRUSHSTYLE_DIAGCROSS      , HS_DIAGCROSS      } };
  238.  
  239.  
  240.  
  241.  
  242. /******************************************************************************\
  243. *                            FUNCTION PROTOTYPES
  244. \******************************************************************************/
  245.  
  246. LRESULT CALLBACK MainWndProc   (HWND, UINT, WPARAM, LPARAM);
  247. LRESULT CALLBACK AboutDlgProc  (HWND, UINT, WPARAM, LPARAM);
  248. LRESULT CALLBACK AbortDlgProc  (HWND, UINT, WPARAM, LPARAM);
  249.  
  250. BOOL    CALLBACK AbortProc     (HDC, int);
  251.  
  252. void    InvalidateClient       (void);
  253. void    RefreshPrinterCombobox (HWND);
  254. void    PrintThread            (LPVOID);
  255.