|
|
1.1.1.2 ! root 1: ! 2: /******************************************************************************\ ! 3: * This is a part of the Microsoft Source Code Samples. ! 4: * Copyright (C) 1993 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: 1.1 root 12: /******************************************************************************\ 13: * 14: * PRINTER.H 15: * 16: \******************************************************************************/ 17: 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_SOLID 502 78: #define IDM_BRUSHSTYLE_BDIAGONAL 503 79: #define IDM_BRUSHSTYLE_CROSS 504 80: #define IDM_BRUSHSTYLE_DIAGCROSS 505 81: #define IDM_BRUSHSTYLE_FDIAGONAL 506 82: #define IDM_BRUSHSTYLE_HORIZONTAL 507 83: #define IDM_BRUSHSTYLE_VERTICAL 508 84: #define IDM_BRUSHSTYLE_FDIAGONAL1 509 85: #define IDM_BRUSHSTYLE_BDIAGONAL1 510 86: #define IDM_BRUSHSTYLE_DENSE1 511 87: #define IDM_BRUSHSTYLE_DENSE2 512 88: #define IDM_BRUSHSTYLE_DENSE3 513 89: #define IDM_BRUSHSTYLE_DENSE4 514 90: #define IDM_BRUSHSTYLE_DENSE5 515 91: #define IDM_BRUSHSTYLE_DENSE6 516 92: #define IDM_BRUSHSTYLE_DENSE7 517 93: #define IDM_BRUSHSTYLE_DENSE8 518 94: #define IDM_BRUSHSTYLE_NOSHADE 519 95: #define IDM_BRUSHSTYLE_HALFTONE 520 96: 97: #define IDM_TEXTCOLOR 601 98: 99: #define ID_COMBOBOX 701 // toolbar combobox id 100: 101: #define MAIN_ICON 1 102: #define MAIN_MENU_NAME "MENU" 103: #define MAIN_CLASS_NAME "PRINTER" 104: #define MAIN_WND_TITLE "Printer Sample Application" 105: #define MAIN_CLASS_STYLE CS_HREDRAW | CS_VREDRAW 106: #define MAIN_WND_STYLE WS_OVERLAPPEDWINDOW 107: 108: #define MAX_MAP_MODES 8 // # items in gaMMLookup 109: #define MAX_PENWIDTHS 8 // # items in gaPenWidths 110: #define MAX_PENSTYLES 7 // # items in gaPenStyles 111: #define MAX_BRUSHSTYLES 19 // # items in gaBrushStyles 112: 113: #define ERR_MOD_NAME "Error: PRINTER.EXE (PRINTER.C)" 114: 115: 116: 117: /******************************************************************************\ 118: * TYPEDEFS 119: \******************************************************************************/ 120: 121: typedef struct tagMAPMODELOOKUP 122: { 123: WORD wMenuItem; 124: int iMapMode; 125: 126: } MAPMODELOOKUP; 127: 128: typedef struct tagGRAPHICLOOKUP 129: { 130: WORD wMenuItem; 131: DWORD dwGraphic; 132: 133: } GRAPHICLOOKUP; 134: 135: typedef struct tagPENWIDTHLOOKUP 136: { 137: WORD wMenuItem; 138: int iPenWidth; 139: 140: } PENWIDTHLOOKUP; 141: 142: typedef struct tagPENSTYLELOOKUP 143: { 144: WORD wMenuItem; 145: int iPenStyle; 146: 147: } PENSTYLELOOKUP; 148: 149: typedef struct tagBRUSHSTYLELOOKUP 150: { 151: WORD wMenuItem; 152: int iBrushStyle; 153: 154: } BRUSHSTYLELOOKUP; 155: 156: typedef struct tagSTATUSBARLOOKUP 157: { 158: WORD wMenuItem; 159: LPCSTR szText; 160: 161: } STATUSBARLOOKUP; 162: 163: 164: 165: /******************************************************************************\ 166: * GLOBAL VARS 167: \******************************************************************************/ 168: 169: HANDLE ghInst; // app instance handle 170: HWND ghwndMain; // main app window handle 171: HWND ghwndAbort; // Abort dialog handle 172: LONG glcyMenu; // menu height 173: DWORD gdwGraphicsOptions = DRAWAXIS; // current graphic options (to display) 174: int giMapMode = MM_TEXT; // current map mode 175: HDC ghdc; // device context to print on 176: BOOL gbAbort; // AbortProc return code 177: 178: char gszDeviceName[BUFSIZE]; // current device name 179: char gszPort [BUFSIZE]; // current port 180: char gszDriverName[BUFSIZE]; // current driver name 181: 182: DWORD gdwPenColor = 0x00ff00; // current pen color 183: DWORD gdwBrushColor = 0x0000ff; // current brush color 184: DWORD gdwTextColor = 0xff0000; // current text color 185: 186: int giPenStyle = PS_SOLID; // current pen style 187: int giPenWidth = 1; // current pen width 188: int giBrushStyle = HS_SOLID; // current brush style 189: 190: MAPMODELOOKUP gaMMLookup[] = 191: 192: { { IDM_HIENGLISH , MM_HIENGLISH }, 193: { IDM_HIMETRIC , MM_HIMETRIC }, 194: { IDM_LOENGLISH , MM_LOENGLISH }, 195: { IDM_LOMETRIC , MM_LOMETRIC }, 196: { IDM_TWIPS , MM_TWIPS }, 197: { IDM_ISOTROPIC , MM_ISOTROPIC }, 198: { IDM_ANISOTROPIC, MM_ANISOTROPIC }, 199: { IDM_TEXT , MM_TEXT } }; 200: 201: GRAPHICLOOKUP gaGraphicLookup[] = 202: 203: { { IDM_ARC , ARC }, 204: { IDM_ELLIPSE , ELLIPSE }, 205: { IDM_LINETO , LINETO }, 206: { IDM_PIE , PIE }, 207: { IDM_PLGBLT , PLG_BLT }, 208: { IDM_POLYBEZIER , POLYBEZIER }, 209: { IDM_POLYGON , POLYGON }, 210: { IDM_POLYLINE , POLYLINE }, 211: { IDM_POLYPOLYGON, POLYPOLYGON }, 212: { IDM_RECTANGLE , RECTANGLE }, 213: { IDM_ROUNDRECT , ROUNDRECT }, 214: { IDM_STRETCHBLT , STRETCH_BLT } }; 215: 216: PENWIDTHLOOKUP gaPenWidths[] = 217: 218: { { IDM_PENWIDTH_1, 1 }, 219: { IDM_PENWIDTH_2, 2 }, 220: { IDM_PENWIDTH_3, 3 }, 221: { IDM_PENWIDTH_4, 4 }, 222: { IDM_PENWIDTH_5, 5 }, 223: { IDM_PENWIDTH_6, 6 }, 224: { IDM_PENWIDTH_7, 7 }, 225: { IDM_PENWIDTH_8, 8 } }; 226: 227: PENSTYLELOOKUP gaPenStyles[] = 228: 229: { { IDM_PENCOLOR_SOLID , PS_SOLID }, 230: { IDM_PENCOLOR_DASH , PS_DASH }, 231: { IDM_PENCOLOR_DOT , PS_DOT }, 232: { IDM_PENCOLOR_DASHDOT , PS_DASHDOT }, 233: { IDM_PENCOLOR_DASHDOTDOT , PS_DASHDOTDOT }, 234: { IDM_PENCOLOR_NULL , PS_NULL }, 235: { IDM_PENCOLOR_INSIDEFRAME, PS_INSIDEFRAME} }; 236: 237: BRUSHSTYLELOOKUP gaBrushStyles[] = 238: 239: { { IDM_BRUSHSTYLE_SOLID , HS_SOLID }, 240: { IDM_BRUSHSTYLE_BDIAGONAL , HS_BDIAGONAL }, 241: { IDM_BRUSHSTYLE_CROSS , HS_CROSS }, 242: { IDM_BRUSHSTYLE_DIAGCROSS , HS_DIAGCROSS }, 243: { IDM_BRUSHSTYLE_FDIAGONAL , HS_FDIAGONAL }, 244: { IDM_BRUSHSTYLE_HORIZONTAL, HS_HORIZONTAL}, 245: { IDM_BRUSHSTYLE_VERTICAL , HS_VERTICAL }, 246: { IDM_BRUSHSTYLE_FDIAGONAL1, HS_FDIAGONAL1}, 247: { IDM_BRUSHSTYLE_BDIAGONAL1, HS_BDIAGONAL1}, 248: { IDM_BRUSHSTYLE_DENSE1 , HS_DENSE1 }, 249: { IDM_BRUSHSTYLE_DENSE2 , HS_DENSE2 }, 250: { IDM_BRUSHSTYLE_DENSE3 , HS_DENSE3 }, 251: { IDM_BRUSHSTYLE_DENSE4 , HS_DENSE4 }, 252: { IDM_BRUSHSTYLE_DENSE5 , HS_DENSE5 }, 253: { IDM_BRUSHSTYLE_DENSE6 , HS_DENSE6 }, 254: { IDM_BRUSHSTYLE_DENSE7 , HS_DENSE7 }, 255: { IDM_BRUSHSTYLE_DENSE8 , HS_DENSE8 }, 256: { IDM_BRUSHSTYLE_NOSHADE , HS_NOSHADE }, 257: { IDM_BRUSHSTYLE_HALFTONE , HS_HALFTONE } }; 258: 259: 260: 261: /******************************************************************************\ 262: * FUNCTION PROTOTYPES 263: \******************************************************************************/ 264: 265: LRESULT CALLBACK MainWndProc (HWND, UINT, WPARAM, LPARAM); 266: LRESULT CALLBACK AboutDlgProc (HWND, UINT, WPARAM, LPARAM); 267: LRESULT CALLBACK AbortDlgProc (HWND, UINT, WPARAM, LPARAM); 268: 269: BOOL CALLBACK AbortProc (HDC, int); 270: 271: void InvalidateClient (void); 272: void RefreshPrinterCombobox (HWND); 273: void PrintThread (LPVOID);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.