/***************************************************************************** * * Copyright (c) 1999, KL GROUP INC. All Rights Reserved. * http://www.klgroup.com * * This file is provided for demonstration and educational uses only. * Permission to use, copy, modify and distribute this file for * any purpose and without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies, and that the name of KL Group not be used in advertising * or publicity pertaining to this material without the specific, * prior written permission of an authorized representative of * KL Group. * * KL GROUP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY * OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. KL GROUP SHALL NOT BE LIABLE FOR ANY * DAMAGES SUFFERED BY USERS AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ #include #include #include #include "olch2d.h" #include "olch3d.h" #include "profile.h" #define DID_OK 501 #define DID_LISTBOX 502 #define DID_CANCEL 503 #define DID_EDITTEXT 504 static HDC ghdc; // device context to print on static HWND ghwndAbort; // Abort dialog handle static HWND ghwndMain; // main app window handle static BOOL gbAbort; // AbortProc return code BOOL CALLBACK AbortProc (HDC hdc, int error) { MSG msg; while (!gbAbort && PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) { if (!ghwndAbort || !IsDialogMessage (ghwndAbort, &msg)) { TranslateMessage (&msg); DispatchMessage (&msg); } } return !gbAbort; } BOOL CALLBACK AbortDlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: ghwndAbort = hwnd; EnableMenuItem (GetSystemMenu (hwnd, FALSE), SC_CLOSE, MF_GRAYED); break; case WM_COMMAND: switch (LOWORD (wParam)) { case ID_CANCEL: gbAbort = TRUE; AbortDoc (ghdc); EnableWindow (ghwndMain, TRUE); DestroyWindow (hwnd); return TRUE; } break; } return 0; } int PrintCharts(HXRT2D h2d, HXRT3D h3d) { DOCINFO di; PRINTDLG pd; RECT rect; ghwndMain = gMainHwnd; memset ((void *) &pd, 0, sizeof(pd)); pd.lStructSize = sizeof(pd); pd.hwndOwner = ghwndMain; pd.Flags = PD_RETURNDC; pd.hInstance = NULL; PrintDlg(&pd); ghdc = pd.hDC; if (!ghdc) { return(0); } /* put up Abort & install the abort procedure */ gbAbort = FALSE; ghwndAbort = CreateDialog(ghInst, "Abort", ghwndMain, (DLGPROC)AbortDlgProc); EnableWindow(ghwndMain, FALSE); // SetAbortProc(ghdc, AbortProc); memset ((void *) &di, 0, sizeof(di)); di.cbSize = sizeof(di); di.lpszDocName = "Profile Charts"; di.lpszOutput = NULL; /* print it */ StartDoc (ghdc, &di); StartPage (ghdc); rect.top = (int) (10.0*GetDeviceCaps(ghdc, VERTRES)/100.0); /* 10% */ rect.bottom = (int) (45.0*GetDeviceCaps(ghdc, VERTRES)/100.0); /* 45% */ rect.left = (int) (10.0*GetDeviceCaps(ghdc, HORZRES)/100.0); /* 10% */ rect.right = (int) (90.0*GetDeviceCaps(ghdc, HORZRES)/100.0); /* 90% */ XrtDrawToDC(chart2d, ghdc, XRT_DRAW_METAFILE, XRT_DRAWSCALE_TOFIT, rect.left, rect.top, (rect.right - rect.left), (rect.bottom - rect.top)); rect.top = (int) (50.0*GetDeviceCaps(ghdc, VERTRES)/100.0); /* 50% */ rect.bottom = (int) (90.0*GetDeviceCaps(ghdc, VERTRES)/100.0); /* 90% */ rect.left = (int) (10.0*GetDeviceCaps(ghdc, HORZRES)/100.0); /* 10% */ rect.right = (int) (90.0*GetDeviceCaps(ghdc, HORZRES)/100.0); /* 90% */ Xrt3dDrawToDC(chart3d, ghdc, XRT_DRAW_METAFILE, XRT_DRAWSCALE_TOFIT, rect.left, rect.top, (rect.right - rect.left), (rect.bottom - rect.top)); EndPage (ghdc); EndDoc (ghdc); DeleteDC (ghdc); if (!gbAbort) { EnableWindow (ghwndMain, TRUE); DestroyWindow (ghwndAbort); } return(1); }