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

📄 printsetup.cpp

📁 这是本人两年前兼职为某个公司做的石油钻进设计软件
💻 CPP
字号:
// Printsetup.cpp : implementation file
//

#include "stdafx.h"
#include "cvenus.h"
#include "Printsetup.h"
#include "spreadsheet.h"
#include "spreadpreview.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPrintsetup dialog

CPrintsetup::CPrintsetup(CSpreadSheet* pSJSR,CSpreadPreview*	pprintview,CWnd* pParent /*=NULL*/)
	: CDialog(CPrintsetup::IDD, pParent)
{
	m_pSJSR	= pSJSR;
	m_pprintview = pprintview;
	//{{AFX_DATA_INIT(CPrintsetup)
	m_fanwei = -1;
	m_rowtitle = FALSE;
	m_coltitle = FALSE;
	m_gridline = FALSE;
	m_border = FALSE;
	m_data = FALSE;
	m_color = FALSE;
	m_shadow = FALSE;
	m_page1 = 0;
	m_page2 = 0;
	m_right = 0;
	m_top = 0;
	m_bottom = 0;
	m_left = 0;
	m_yema = FALSE;
	m_ymlocation = -1;
	m_header = _T("");
	m_footer = _T("");
	m_headlocation = -1;
	m_footlocation = -1;
	//}}AFX_DATA_INIT
	m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON_PRINT);
}


void CPrintsetup::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPrintsetup)
	DDX_Radio(pDX, IDC_YMFW1, m_fanwei);
	DDX_Check(pDX, IDC_CHECK1, m_rowtitle);
	DDX_Check(pDX, IDC_CHECK2, m_coltitle);
	DDX_Check(pDX, IDC_CHECK3, m_gridline);
	DDX_Check(pDX, IDC_CHECK4, m_border);
	DDX_Check(pDX, IDC_CHECK5, m_data);
	DDX_Check(pDX, IDC_CHECK6, m_color);
	DDX_Check(pDX, IDC_CHECK7, m_shadow);
	DDX_Text(pDX, IDC_YMEDIT1, m_page1);
	DDV_MinMaxInt(pDX, m_page1, 1, 100);
	DDX_Text(pDX, IDC_YMEDIT2, m_page2);
	DDV_MinMaxInt(pDX, m_page2, 1, 1000);
	DDX_Text(pDX, IDC_EDIT4, m_right);
	DDV_MinMaxLong(pDX, m_right, 1, 10);
	DDX_Text(pDX, IDC_EDIT5, m_top);
	DDV_MinMaxLong(pDX, m_top, 1, 10);
	DDX_Text(pDX, IDC_EDIT6, m_bottom);
	DDX_Text(pDX, IDC_EDIT3, m_left);
	DDV_MinMaxLong(pDX, m_left, 1, 10);
	DDX_Check(pDX, IDC_CHECK8, m_yema);
	DDX_Radio(pDX, IDC_YMRADIO1, m_ymlocation);
	DDX_Text(pDX, IDC_EDIT7, m_header);
	DDV_MaxChars(pDX, m_header, 30);
	DDX_Text(pDX, IDC_EDIT8, m_footer);
	DDV_MaxChars(pDX, m_footer, 30);
	DDX_Radio(pDX, IDC_YM1, m_headlocation);
	DDX_Radio(pDX, IDC_YJ1, m_footlocation);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPrintsetup, CDialog)
	//{{AFX_MSG_MAP(CPrintsetup)
	ON_BN_CLICKED(IDC_YMFW1, OnYmfw1)
	ON_BN_CLICKED(IDC_YMFW2, OnYmfw2)
	ON_BN_CLICKED(IDC_YMFW3, OnYmfw3)
	ON_BN_CLICKED(IDC_YMFW4, OnYmfw4)
	ON_BN_CLICKED(IDC_CHECK8, OnCheck8)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPrintsetup message handlers

void CPrintsetup::OnYmfw1() 
{
	GetDlgItem(IDC_YMEDIT1)->EnableWindow(FALSE);
    GetDlgItem(IDC_YMEDIT2)->EnableWindow(FALSE);	
}

void CPrintsetup::OnYmfw2() 
{
	GetDlgItem(IDC_YMEDIT1)->EnableWindow(FALSE);
    GetDlgItem(IDC_YMEDIT2)->EnableWindow(FALSE);	
}

void CPrintsetup::OnYmfw3() 
{
	GetDlgItem(IDC_YMEDIT1)->EnableWindow(FALSE);
    GetDlgItem(IDC_YMEDIT2)->EnableWindow(FALSE);	
}

void CPrintsetup::OnYmfw4() 
{
	GetDlgItem(IDC_YMEDIT1)->EnableWindow(TRUE);
    GetDlgItem(IDC_YMEDIT2)->EnableWindow(TRUE);
}

void CPrintsetup::OnCheck8() 
{
   UpdateData(TRUE); 
	if(m_yema)
	 {
		 GetDlgItem(IDC_YMRADIO1)->EnableWindow(TRUE);
         GetDlgItem(IDC_YMRADIO2)->EnableWindow(TRUE);
		 GetDlgItem(IDC_YMRADIO3)->EnableWindow(TRUE);
		 GetDlgItem(IDC_YMRADIO4)->EnableWindow(TRUE);
		 GetDlgItem(IDC_YMRADIO5)->EnableWindow(TRUE);
		 GetDlgItem(IDC_YMRADIO6)->EnableWindow(TRUE);
		 CheckDlgButton(IDC_YMRADIO5,1);
	 }
	 else
	 {
         GetDlgItem(IDC_YMRADIO1)->EnableWindow(FALSE);
         GetDlgItem(IDC_YMRADIO2)->EnableWindow(FALSE);
		 GetDlgItem(IDC_YMRADIO3)->EnableWindow(FALSE);
		 GetDlgItem(IDC_YMRADIO4)->EnableWindow(FALSE);
		 GetDlgItem(IDC_YMRADIO5)->EnableWindow(FALSE);
		 GetDlgItem(IDC_YMRADIO6)->EnableWindow(FALSE);
	 }
	
}

void CPrintsetup::OnOK() 
{
	UpdateData(TRUE);
	m_pSJSR->SetPrintRowHeaders(m_rowtitle);
    m_pSJSR->SetPrintColHeaders(m_coltitle);
    m_pSJSR->SetPrintGrid(m_gridline);
	m_pSJSR->SetPrintBorder(m_border);
	m_pSJSR->SetPrintUseDataMax(m_data);
    m_pSJSR->SetPrintColor(m_color);
	m_pSJSR->SetPrintShadows(m_shadow);
	m_pSJSR->SetPrintMarginLeft(m_left*567);
    m_pSJSR->SetPrintMarginRight(m_right*567);
	m_pSJSR->SetPrintMarginTop(m_top*567);
	m_pSJSR->SetPrintMarginBottom(m_bottom*567);
    
	switch(m_headlocation)
	{
	case 0:
         if(m_yema==TRUE)
		 {
			  switch(m_ymlocation)
			  {
				  case 0:
					  m_header="/l/p/n/l"+m_header+"/n";
					  break;
				  case 1:
					  m_header="/c/p/n/l"+m_header+"/n";
					  break;
				  case 2:
					  m_header="/r/p/n/l"+m_header+"/n";
					  break;
				  default:
                      m_header="/l"+m_header+"/n";
			  }
		 }
		 else
		 {
			   m_header="/l"+m_header+"/n";
		 }
         break;
    case 1:
		 if(m_yema==TRUE)
		 {
			  switch(m_ymlocation)
			  {
				  case 0:
					  m_header="/l/p/n/c"+m_header+"/n";
					  break;
				  case 1:
					  m_header="/c/p/n/c"+m_header+"/n";
					  break;
				  case 2:
					  m_header="/r/p/n/c"+m_header+"/n";
					  break;
				  default:
                      m_header="/c"+m_header+"/n";
			  }
		 }
		 else
		 {
			   m_header="/c"+m_header+"/n";
		 }
		break;
	case 2:
		 if(m_yema==TRUE)
		 {
			  switch(m_ymlocation)
			  {
				  case 0:
					  m_header="/l/p/n/r"+m_header+"/n";
					  break;
				  case 1:
					  m_header="/c/p/n/r"+m_header+"/n";
					  break;
				  case 2:
					  m_header="/r/p/n/r"+m_header+"/n";
					  break;
				  default:
                      m_header="/r"+m_header+"/n";
			  }
		 }
		 else
		 {
			   m_header="/r"+m_header+"/n";
		 }	 
		 break;
	}
    m_pSJSR->SetPrintHeader(m_header); 	

	switch(m_footlocation)
	{
	case 0:
         if(m_yema==TRUE)
		 {
			  switch(m_ymlocation)
			  {
				  case 3:
					  m_footer="/l/p/n/l"+m_footer;
					  break;
				  case 4:
					  m_footer="/c/p/n/l"+m_footer;
					  break;
				  case 5:
					  m_footer="/r/p/n/l"+m_footer;
					  break;
				  default:
                      m_footer="/l"+m_footer;
			  }
		 }
		 else
		 {
			   m_footer="/l"+m_footer;
		 } 
         break;
    case 1:
		 if(m_yema==TRUE)
		 {
			  switch(m_ymlocation)
			  {
				  case 3:
					  m_footer="/l/p/n/c"+m_footer;
					  break;
				  case 4:
					  m_footer="/c/p/n/c"+m_footer;
					  break;
				  case 5:
					  m_footer="/r/p/n/c"+m_footer;
					  break;
				  default:
                      m_footer="/c"+m_footer;
			  }
		 }
		 else
		 {
			   m_footer="/c"+m_footer;
		 } 
		 break;
    case 2:
		 if(m_yema==TRUE)
		 {
			  switch(m_ymlocation)
			  {
				  case 3:
					  m_footer="/l/p/n/r"+m_footer;
					  break;
				  case 4:
					  m_footer="/c/p/n/r"+m_footer;
					  break;
				  case 5:
					  m_footer="/r/p/n/r"+m_footer;
					  break;
                  default:
                      m_footer="/r"+m_footer;
			  }
		 }
		 else
		 {
			    m_footer="/r"+m_footer;
		 } 
		 break;
	}
	m_pSJSR->SetPrintFooter(m_footer);
	
	switch(m_fanwei)
   {
   case 0:
	  m_pSJSR->SetPrintType(0);	
	  break;
   case 1:
	  m_pSJSR->SetCol(m_pSJSR->GetSelBlockCol());
	  m_pSJSR->SetCol2(m_pSJSR->GetSelBlockCol2());
	  m_pSJSR->SetRow(m_pSJSR->GetSelBlockRow());
      m_pSJSR->SetRow2(m_pSJSR->GetSelBlockRow2());
      m_pSJSR->SetPrintType(1);	
	  break;
   case 2:
	  m_pSJSR->SetPrintType(2);
	  break;
   case 3:
	  m_pSJSR->SetPrintPageStart(m_page1);
      m_pSJSR->SetPrintPageEnd(m_page2);
	  m_pSJSR->SetPrintType(3); 
	  break;
   }
    m_pprintview->SetHWndSpread(m_pSJSR->GetHWnd());//与要打印表格连接
 
	CDialog::OnOK();
}

BOOL CPrintsetup::OnInitDialog() 
{
	CDialog::OnInitDialog();
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	m_left=2;
	m_right=2;
	m_top=2;
	m_bottom=2;
	m_page1=1;
	m_page2=1;
	m_header="";
	m_footer="";
	UpdateData(FALSE);
	CheckDlgButton(IDC_YMFW1,1);
    CheckDlgButton(IDC_CHECK1,1);
    CheckDlgButton(IDC_CHECK2,1);
	CheckDlgButton(IDC_CHECK3,1);
	CheckDlgButton(IDC_CHECK4,1);
	CheckDlgButton(IDC_CHECK5,1);
	CheckDlgButton(IDC_CHECK6,1);
	CheckDlgButton(IDC_CHECK7,1);
	CheckDlgButton(IDC_YM2,1);
	CheckDlgButton(IDC_YJ2,1);	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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