?? browdlg.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 + -