⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfxprint.cpp

📁 Delphi Component - Chart Fx
💻 CPP
字号:
// CfxPrint.cpp : implementation file
//

#include "stdafx.h"
#include "cfx98.h"
#include "CfxPrint.h"



#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCfxPrint dialog


CCfxPrint::CCfxPrint(CWnd* pParent /*=NULL*/)
	: CDialog(CCfxPrint::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCfxPrint)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CCfxPrint::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCfxPrint)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP

	// ***CFX***
	// Do not use class wizard to generate these. It will cause the generation of unecesary classes
	DDX_Control(pDX, IDC_CHART1, m_ChartFX);
	if (!pDX->m_bSaveAndValidate) // Link Chart FX pointer to control window
		m_pChartFX = m_ChartFX.GetControlUnknown();
	// ***CFX***

}


BEGIN_MESSAGE_MAP(CCfxPrint, CDialog)
	//{{AFX_MSG_MAP(CCfxPrint)
	ON_BN_CLICKED(IDC_PORTRAIT, OnPortrait)
	ON_BN_CLICKED(IDC_LANDSCAPE, OnLandscape)
	ON_BN_CLICKED(IDC_PRINTSETUPDLG, OnPrintsetupdlg)
	ON_BN_CLICKED(IDC_FORCECOLORS, OnForcecolors)
	ON_BN_CLICKED(IDC_PAGESETUP, OnPagesetup)
	ON_BN_CLICKED(IDC_PRINTALL, OnPrintall)
	ON_BN_CLICKED(IDC_PERPAGE, OnPerpage)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCfxPrint message handlers

BOOL CCfxPrint::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	m_pChartFX = NULL;
	return CDialog::DestroyWindow();
}

void CCfxPrint::OnPortrait() 
{
    m_pChartFX->Printer->Orientation = ORIENTATION_PORTRAIT;
    m_pChartFX->ToolBarObj->Item[0]->CommandID = CFX_ID_PRINT;
	
}

void CCfxPrint::OnLandscape() 
{
    m_pChartFX->Printer->Orientation = ORIENTATION_LANDSCAPE;
    m_pChartFX->ToolBarObj->Item[0]->CommandID = CFX_ID_PRINT;
	
	
}

void CCfxPrint::OnPrintsetupdlg() 
{
    m_pChartFX->Printer->Orientation = ORIENTATION_DEFAULT;
    m_pChartFX->ToolBarObj->Item[0]->CommandID = CFX_ID_DLGPRINT;
	
	
}

void CCfxPrint::OnForcecolors() 
{
	if (IsDlgButtonChecked(IDC_FORCECOLORS))
		m_pChartFX->Printer->ForceColors = TRUE;
	else
		m_pChartFX->Printer->ForceColors = FALSE;
}	

void CCfxPrint::OnPagesetup() 
{
    m_pChartFX->ShowDialog(CDIALOG_PAGESETUP, 0	);
	
}

void CCfxPrint::OnPrintall() 
{
    
	CPrintDialog dlgPrint(TRUE,PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_HIDEPRINTTOFILE | PD_NOSELECTION,this);

	// Show printer setup dialog
	if (IsDlgButtonChecked(IDC_PRINTSETUPDLG)) {
		dlgPrint.DoModal();
		
		HDC hDC;

		hDC = dlgPrint.CreatePrinterDC();
		if (!hDC) {
			MessageBox("Failed Initializing Printer");
			return;
		}

		m_pChartFX->Printer->hDC =  (long) hDC;
	}

    m_pChartFX->PrintIt(0, 0);
    m_pChartFX->Printer->hDC = 0;

}

void CCfxPrint::OnPerpage() 
{
	long lLastPoint, nTotPoints;
	int nPage, nTotPages, m;
	char buffer[100];
	BOOL bQuit;

	CPrintDialog dlgPrint(TRUE,PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS | PD_HIDEPRINTTOFILE | PD_NOSELECTION,this);
    
    if (IsDlgButtonChecked(IDC_PRINTSETUPDLG)) {
		dlgPrint.DoModal();
    
		HDC hDC;

		hDC = dlgPrint.CreatePrinterDC();
		if (!hDC) {
			MessageBox("Failed Initializing Printer");
			return;
		}

		m_pChartFX->Printer->hDC =  (long) hDC;
	}

            
    bQuit = FALSE;
    nPage = 1;
    nTotPoints = m_pChartFX->NValues;
    nTotPages = -1;
	while (!bQuit) {
    
        lLastPoint = m_pChartFX->PrintIt(nPage, nPage); // Print one page
        
        if (lLastPoint && (lLastPoint < nTotPoints)) {  // Is there more ?
            if (nTotPages < 0)
                nTotPages = (int) ((nTotPoints / lLastPoint) + 0.5); // Calculate total
			wsprintf(buffer, "Page %d of %d Done.\n Another Page?", nPage, nTotPages); 
			m =  this->MessageBox(buffer, "Another Page?", MB_YESNO);
  
            if (m!=IDYES)
                bQuit = TRUE;
            
            nPage = nPage + 1; // Next page
        } else
            bQuit = TRUE;
        
    }
    
    m_pChartFX->Printer->hDC = 0; //Restore
    

	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -