0008Dlg.cpp
资源名称:VCdayin.rar [点击查看]
上传用户:smsj_tj
上传日期:2022-05-05
资源大小:187k
文件大小:15k
源码类别:
打印编程
开发平台:
Visual C++
- // 0008Dlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "0008.h"
- #include "0008Dlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- //{{AFX_MSG(CAboutDlg)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMy0008Dlg dialog
- CMy0008Dlg::CMy0008Dlg(CWnd* pParent /*=NULL*/)
- : CDialog(CMy0008Dlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CMy0008Dlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CMy0008Dlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMy0008Dlg)
- DDX_Control(pDX, IDCANCEL, m_cancel);
- DDX_Control(pDX, IDOK, m_ok);
- DDX_Control(pDX, IDC_CWPRINTOCXCTRL1, m_yyy);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CMy0008Dlg, CDialog)
- //{{AFX_MSG_MAP(CMy0008Dlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMy0008Dlg message handlers
- BOOL CMy0008Dlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // Add "About..." menu item to system menu.
- // IDM_ABOUTBOX must be in the system command range.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
- // TODO: Add extra initialization here
- return TRUE; // return TRUE unless you set the focus to a control
- }
- void CMy0008Dlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
- void CMy0008Dlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CMy0008Dlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CMy0008Dlg::OnOK()
- {
- //没有特殊声明的所有单位默认是 0.1毫米
- //@**#---2002-12-26 16:40:08 (王继南)---#**@
- //
- //#define DMPAPER_FIRST DMPAPER_LETTER
- //#define DMPAPER_LETTER 1 /* Letter 8 1/2 x 11 in */
- //#define DMPAPER_LETTERSMALL 2 /* Letter Small 8 1/2 x 11 in */
- //#define DMPAPER_TABLOID 3 /* Tabloid 11 x 17 in */
- //#define DMPAPER_LEDGER 4 /* Ledger 17 x 11 in */
- //#define DMPAPER_LEGAL 5 /* Legal 8 1/2 x 14 in */
- //#define DMPAPER_STATEMENT 6 /* Statement 5 1/2 x 8 1/2 in */
- //#define DMPAPER_EXECUTIVE 7 /* Executive 7 1/4 x 10 1/2 in */
- //#define DMPAPER_A3 8 /* A3 297 x 420 mm */
- //#define DMPAPER_A4 9 /* A4 210 x 297 mm */
- //#define DMPAPER_A4SMALL 10 /* A4 Small 210 x 297 mm */
- //#define DMPAPER_A5 11 /* A5 148 x 210 mm */
- //#define DMPAPER_B4 12 /* B4 (JIS) 250 x 354 */
- //#define DMPAPER_B5 13 /* B5 (JIS) 182 x 257 mm */
- //#define DMPAPER_FOLIO 14 /* Folio 8 1/2 x 13 in */
- //#define DMPAPER_QUARTO 15 /* Quarto 215 x 275 mm */
- //#define DMPAPER_10X14 16 /* 10x14 in */
- //#define DMPAPER_11X17 17 /* 11x17 in */
- //#define DMPAPER_NOTE 18 /* Note 8 1/2 x 11 in */
- //#define DMPAPER_ENV_9 19 /* Envelope #9 3 7/8 x 8 7/8 */
- //#define DMPAPER_ENV_10 20 /* Envelope #10 4 1/8 x 9 1/2 */
- //#define DMPAPER_ENV_11 21 /* Envelope #11 4 1/2 x 10 3/8 */
- //#define DMPAPER_ENV_12 22 /* Envelope #12 4 276 x 11 */
- //#define DMPAPER_ENV_14 23 /* Envelope #14 5 x 11 1/2 */
- //#define DMPAPER_CSHEET 24 /* C size sheet */
- //#define DMPAPER_DSHEET 25 /* D size sheet */
- //#define DMPAPER_ESHEET 26 /* E size sheet */
- //#define DMPAPER_ENV_DL 27 /* Envelope DL 110 x 220mm */
- //#define DMPAPER_ENV_C5 28 /* Envelope C5 162 x 229 mm */
- //#define DMPAPER_ENV_C3 29 /* Envelope C3 324 x 458 mm */
- //#define DMPAPER_ENV_C4 30 /* Envelope C4 229 x 324 mm */
- //#define DMPAPER_ENV_C6 31 /* Envelope C6 114 x 162 mm */
- //#define DMPAPER_ENV_C65 32 /* Envelope C65 114 x 229 mm */
- //#define DMPAPER_ENV_B4 33 /* Envelope B4 250 x 353 mm */
- //#define DMPAPER_ENV_B5 34 /* Envelope B5 176 x 250 mm */
- //#define DMPAPER_ENV_B6 35 /* Envelope B6 176 x 125 mm */
- //#define DMPAPER_ENV_ITALY 36 /* Envelope 110 x 230 mm */
- //#define DMPAPER_ENV_MONARCH 37 /* Envelope Monarch 3.875 x 7.5 in */
- //#define DMPAPER_ENV_PERSONAL 38 /* 6 3/4 Envelope 3 5/8 x 6 1/2 in */
- //#define DMPAPER_FANFOLD_US 39 /* US Std Fanfold 14 7/8 x 11 in */
- //#define DMPAPER_FANFOLD_STD_GERMAN 40 /* German Std Fanfold 8 1/2 x 12 in */
- //#define DMPAPER_FANFOLD_LGL_GERMAN 41 /* German Legal Fanfold 8 1/2 x 13 in */
- //#if(WINVER >= 0x0400)
- //#define DMPAPER_ISO_B4 42 /* B4 (ISO) 250 x 353 mm */
- //#define DMPAPER_JAPANESE_POSTCARD 43 /* Japanese Postcard 100 x 148 mm */
- //#define DMPAPER_9X11 44 /* 9 x 11 in */
- //#define DMPAPER_10X11 45 /* 10 x 11 in */
- //#define DMPAPER_15X11 46 /* 15 x 11 in */
- //#define DMPAPER_ENV_INVITE 47 /* Envelope Invite 220 x 220 mm */
- //#define DMPAPER_RESERVED_48 48 /* RESERVED--DO NOT USE */
- //#define DMPAPER_RESERVED_49 49 /* RESERVED--DO NOT USE */
- //#define DMPAPER_LETTER_EXTRA 50 /* Letter Extra 9 275 x 12 in */
- //#define DMPAPER_LEGAL_EXTRA 51 /* Legal Extra 9 275 x 15 in */
- //#define DMPAPER_TABLOID_EXTRA 52 /* Tabloid Extra 11.69 x 18 in */
- //#define DMPAPER_A4_EXTRA 53 /* A4 Extra 9.27 x 12.69 in */
- //#define DMPAPER_LETTER_TRANSVERSE 54 /* Letter Transverse 8 275 x 11 in */
- //#define DMPAPER_A4_TRANSVERSE 55 /* A4 Transverse 210 x 297 mm */
- //#define DMPAPER_LETTER_EXTRA_TRANSVERSE 56 /* Letter Extra Transverse 9275 x 12 in */
- //#define DMPAPER_A_PLUS 57 /* SuperA/SuperA/A4 227 x 356 mm */
- //#define DMPAPER_B_PLUS 58 /* SuperB/SuperB/A3 305 x 487 mm */
- //#define DMPAPER_LETTER_PLUS 59 /* Letter Plus 8.5 x 12.69 in */
- //#define DMPAPER_A4_PLUS 60 /* A4 Plus 210 x 330 mm */
- //#define DMPAPER_A5_TRANSVERSE 61 /* A5 Transverse 148 x 210 mm */
- //#define DMPAPER_B5_TRANSVERSE 62 /* B5 (JIS) Transverse 182 x 257 mm */
- //#define DMPAPER_A3_EXTRA 63 /* A3 Extra 322 x 445 mm */
- //#define DMPAPER_A5_EXTRA 64 /* A5 Extra 174 x 235 mm */
- //#define DMPAPER_B5_EXTRA 65 /* B5 (ISO) Extra 201 x 276 mm */
- //#define DMPAPER_A2 66 /* A2 420 x 594 mm */
- //#define DMPAPER_A3_TRANSVERSE 67 /* A3 Transverse 297 x 420 mm */
- //#define DMPAPER_A3_EXTRA_TRANSVERSE 68 /* A3 Extra Transverse 322 x 445 mm */
- //
- //
- //
- m_yyy.BeginCx(); //初始化
- //纸张设置不是很好目前用mfc类库里的宏定义 设置纸张 缺省 A4
- m_yyy.SetPaperSize(DMPAPER_A4);
- m_yyy.SetSpan(5); //列头字体与上下线的距离
- m_yyy.SetLeftSpace(20); //设置左面开始距离 ,就是内容在左空多大的距离。试试就知道了。
- m_yyy.SetBottomHeight(20); //设置下面留的距离,就是内容剧下面纸边的距离
- m_yyy.SetColSpace(10); // 设置每一列的空隙,例如画线用的空间。
- m_yyy.SetLineSpace(20); // 设置每行之间的距离。
- //以上都有默认值,不设也可以
- //以下是设置报表头 可以加任意多个 例如 日期 ,标题及其它
- //@**#---2002-12-26 13:44:22 (王继南)---#**@
- // AddHeadTitle(short sFontSize/*字体尺寸*/, LPCTSTR lFontName/*字体名称*/,
- // PCTSTR lChangeLine/*是否换行 0 不换行 1换行*/,
- // LPCTSTR lFontB/*字体粗细 B 加粗 其它为细的*/, short sX/*在这行的x坐标*/,
- // LPCTSTR lTitleHead/*标题内容 可为空*/)
- m_yyy.AddHeadTitle(4,"楷体_GB2312","1","B",600,"客户资金流水表");
- m_yyy.AddHeadTitle(2,"宋体","1"," ",1000,"(报表头)");
- //这个方法可以变相的用,例如你可想让行与行间有一定的距离你可以用下面的语句,距离为2毫米
- m_yyy.AddHeadTitle(0,"宋体","1"," ",20,"");
- m_yyy.AddHeadTitle(3,"宋体","1"," ",20,"2002年11月11日");
- //这个方法可以变相的用,例如你可想让行与行间有一定的距离你可以用下面的语句,距离为1毫米
- m_yyy.AddHeadTitle(0,"宋体","1"," ",10,"");
- // 设置报表列头字体大小0-36,是否加粗 B加粗 否则其它 就可以,字体名称
- m_yyy.SetReportColHead(3,"G","宋体");
- // 设置报表内容字体大小0-36,是否加粗 B加粗 否则其它 就可以,字体名称
- m_yyy.SetReportColBody(3,"G","宋体");
- // 单独设置列头,和内容 报表字体的粗细 其实上面就可以完成这个功能
- m_yyy.SetReportHeadFontWeight("B");
- m_yyy.SetReportBodyFontWeight("G");
- //添加列信息
- //AddColInfo(short sFontWidth/*列宽度单位是每个汉字*/, LPCTSTR lAlign/*靠齐方位*/
- //, BOOL bDisplay/*是否显示该列*/, BOOL bPrint/*是否打印该列*/,
- // LPCTSTR lTotalType/*汇总类型*/, LPCTSTR lColType/*列的数据类型*/,
- //LPCTSTR lColName/*列标题*/, LPCTSTR lFieldName/*列名字*/, short sDecWidth/*小数点位数*/)
- m_yyy.AddColInfo(7,"L",true,true,"S","C","资金帐号","zjzh",0);
- m_yyy.AddColInfo(4,"C",true,true,"C","C","客户姓名","xm",0);
- m_yyy.AddColInfo(9,"L",true,true,"C","C","身份证号","sfzh",0);
- m_yyy.AddColInfo(8,"R",true,true,"S","N","资金发生数","zjfss",2);
- m_yyy.AddColInfo(3,"L",true,true,"C","C","流水号","lsh",0);
- m_yyy.AddColInfo(4,"L",true,true,"C","D","发生日期","fsrq",0);
- m_yyy.AddColInfo(10,"L",true,true,"C","C","备注信息","bzxx",0);
- /*@**#---2003-01-14 10:41:08 (王继南)---#**@
- m_yyy.AddColInfo(7,"L",true,true,"S","C","资金帐号","zjzh",0);
- m_yyy.AddColInfo(4,"C",true,true,"C","C","客户姓名","xm",0);
- m_yyy.AddColInfo(9,"L",true,true,"C","C","身份证号","sfzh",0);
- m_yyy.AddColInfo(8,"R",true,true,"S","N","资金发生数","zjfss",2);
- m_yyy.AddColInfo(3,"L",true,true,"C","C","流水号","lsh",0);
- m_yyy.AddColInfo(4,"L",true,true,"C","D","发生日期","fsrq",0);
- m_yyy.AddColInfo(10,"L",true,true,"C","C","备注信息","bzxx",0);
- */
- m_yyy.CreateAndOpen(); //创建dbf库 为了解决数据量大时内存的问题
- //加数据值 别需和上面的列数量相同 否则会出错
- CString strTmp;
- for(long i=0 ; i<500;i++)
- {
- //for(int jj=0;jj<2;jj++)
- {
- strTmp.Format("%d",i);
- m_yyy.AddFieldValue(strTmp.GetBuffer(0));
- // strTmp.Format("%d你",i);
- m_yyy.AddFieldValue("刘德华");
- strTmp.Format("%018d",i);
- m_yyy.AddFieldValue(strTmp.GetBuffer(0));
- m_yyy.AddFieldValue("23.09");
- strTmp.Format("%06d",i);
- m_yyy.AddFieldValue(strTmp.GetBuffer(0));
- m_yyy.AddFieldValue("20010304");
- m_yyy.AddFieldValue("资金存取流水");
- }
- }
- //显示报表窗体
- m_yyy.ShowModal();
- }
- void CMy0008Dlg::OnButton1()
- {
- CString strtmp,strtmp1;
- m_yyy.BeginCx();
- /////////////////////////////
- m_yyy.AddHeadTitle(4,"楷体_GB2312","1","B",500,"原始测量数据报表");
- CTime t=CTime::GetCurrentTime();
- int n=t.GetYear();
- strtmp.Format("%d",n);
- strtmp1=strtmp+"年";
- n=t.GetMonth();
- strtmp.Format("%d",n);
- strtmp1+=strtmp+"月";
- n=t.GetDay();
- strtmp1+=strtmp+"日";
- m_yyy.AddHeadTitle(3,"宋体","1"," ",20,strtmp1);
- m_yyy.AddHeadTitle(0,"宋体","1"," ",10,"");
- m_yyy.SetReportColBody(3,"G","宋体");
- m_yyy.SetReportColHead(3,"G","宋体");
- // m_yyy.SetReportHeadFontWeight(700);
- m_yyy.AddColInfo(6,"R",true,true,"S","N"," 水表编号","nh",0);
- m_yyy.AddColInfo(20,"C",true,true,"C","C","ssssss","llll",0);
- m_yyy.AddColInfo(20,"L",true,true,"C","C","采集时间","oo",0);
- m_yyy.CreateAndOpen();
- // TRACE( "beginn" );
- //@**#---2003-01-14 11:32:19 (王继南)---#**@
- //POSITION pos;
- // for( pos = theApp.m_lDsplyLst.GetHeadPosition(); pos != NULL; )
- // {
- // tag_Dsply * dsp=(tag_Dsply*)theApp.m_lDsplyLst.GetNext(pos);
- // strtmp=dsp->strID;
- // m_yyy.AddFieldValue(strtmp.GetBuffer(0));
- // strtmp=dsp->strRslt;
- // m_yyy.AddFieldValue(strtmp.GetBuffer(0));
- // strtmp=dsp->strTime;
- // m_yyy.AddFieldValue(strtmp.GetBuffer(0));
- //
- //
- // }
- m_yyy.ShowModal();
- }