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

📄 browdlg.cpp

📁 通讯录软件
💻 CPP
字号:
// browdlg.cpp : implementation file
//

#include "stdafx.h"
#include "TXL.h"
#include "browdlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// Cbrowdlg dialog


Cbrowdlg::Cbrowdlg(CWnd* pParent /*=NULL*/)
	: CDialog(Cbrowdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(Cbrowdlg)
	//}}AFX_DATA_INIT
}


void Cbrowdlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cbrowdlg)
	DDX_Control(pDX, IDC_ADODC1, m_adodc);
	DDX_Control(pDX, IDC_DATAGRID3, m_grid);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Cbrowdlg, CDialog)
	//{{AFX_MSG_MAP(Cbrowdlg)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cbrowdlg message handlers

BOOL Cbrowdlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	m_adodc.SetConnectionString("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db2.mdb;Persist Security Info=False");
	CString sql = "select * from txl1";
	m_adodc.SetRecordSource(sql);
	m_adodc.Refresh();
	m_grid.SetRefDataSource(m_adodc.GetRecordset());	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void Cbrowdlg::OnButton1() 
{
if (!UpdateData(TRUE))
{
AfxMessageBox("数据交换有误!");
}
//if (m_strPrintString==_T(""))
//{
//AfxMessageBox("请输入需要打印的文字?quot");
//return;
//}
CPrintDialog dlg(FALSE,
PD_NOPAGENUMS|PD_NOSELECTION,
this);
if(dlg.DoModal() == IDOK)
{
CDC dc;
dc.Attach(dlg.GetPrinterDC());//把打印设备环境附加到DC对象
	int leftmargin;
		leftmargin = dc.GetDeviceCaps(PHYSICALOFFSETX);
		CRect m_rect(-leftmargin,0,dc.GetDeviceCaps(PHYSICALWIDTH)-leftmargin,dc.GetDeviceCaps(PHYSICALHEIGHT));
	dc.StartDoc("printinformation");		
	CFont font150;
	font150.CreatePointFont(150,_T("黑体"),&dc);
	dc.SelectObject(&font150);
	    float ratex =5;
        float ratey =10;
int lx=30;	
	dc.Rectangle(20*ratey,0*ratex,950*ratex,lx*ratex+25*51*ratex);
			//绘制横线
      for(int i=1;i<=50;i++)
	  {
		dc.MoveTo(20*ratey,lx*ratex+25*i*ratex);
		dc.LineTo(950*ratey,lx*ratex+25*i*ratex);
	  }
	  		//绘制竖线
	        for(int i1=1;i<=10;i++)
	  {
		dc.MoveTo(56*ratey*i1,lx*ratex+25*2*ratex);
		dc.LineTo(56*ratey*i1,lx*ratex+25*51*ratex);
		}
	dc.TextOut(20*ratey+50,90,"Quotation(报价单):");
	dc.EndDoc();
}
}

⌨️ 快捷键说明

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