reportDlg.cpp
资源名称:report.rar [点击查看]
上传用户:sdomjx
上传日期:2018-09-19
资源大小:12784k
文件大小:12k
源码类别:
浏览器
开发平台:
Visual Basic
- // reportDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "report.h"
- #include "reportDlg.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()
- /////////////////////////////////////////////////////////////////////////////
- // CReportDlg dialog
- CReportDlg::CReportDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CReportDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CReportDlg)
- // 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 CReportDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CReportDlg)
- DDX_Control(pDX, IDC_REPORTOCXCTRL1, m_rptTest);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CReportDlg, CDialog)
- //{{AFX_MSG_MAP(CReportDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDC_PAGEHEADER, OnPageheader)
- ON_BN_CLICKED(IDC_PAGEFOOTER, OnPagefooter)
- ON_BN_CLICKED(IDC_SPLITPAGER, OnSplitpager)
- ON_BN_CLICKED(IDC_SUBTITLE, OnSubtitle)
- ON_BN_CLICKED(IDC_TABLEBODY, OnTablebody)
- ON_BN_CLICKED(IDC_TABLEHEADER, OnTableheader)
- ON_BN_CLICKED(IDC_TITLE, OnTitle)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CReportDlg message handlers
- BOOL CReportDlg::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 CReportDlg::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 CReportDlg::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 CReportDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CReportDlg::OnButton1()
- {
- m_rptTest.Clear();
- m_rptTest.SetColNums(5);
- m_rptTest.SetFixedLeftMargin(50);
- m_rptTest.SetHeadLine(TRUE);
- m_rptTest.SetPageHeadFormat("Arial", 16, 0, RGB(0, 0, 255), FALSE, FALSE, FALSE);
- m_rptTest.SetPageHead("Page Header: Page 1 2001/12/12");
- m_rptTest.SetTitleFormat("Arial", 48, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
- m_rptTest.SetReportTitle("Title: This is a test");
- m_rptTest.SetSubTitleFormat("Arial", 24, 0, RGB(0, 255, 0), TRUE, TRUE, TRUE);
- m_rptTest.SetReportSubTitleRowsCols(1, 2);
- m_rptTest.SetReportSubTitle("Manager: Jim Carry|Date: 2001/12/12");
- m_rptTest.SetReportHeadHeight(40);
- m_rptTest.SetWidthString("40|100|100|200|200");
- m_rptTest.SetTopString("NO|Name|Detail|Detail|Detail");
- m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
- m_rptTest.SetRecordFormat("Fixedsys", 0, 0, RGB(255, 0, 0), FALSE, FALSE, FALSE);
- m_rptTest.SetRecordBackColor(RGB(0, 255, 0));
- m_rptTest.SetReportHeadBackColor(RGB(255, 0, 255));
- m_rptTest.SetGridHeadLineColor(RGB(0, 0, 255));
- m_rptTest.SetGridLineColor(RGB(255, 0, 255));
- m_rptTest.SetFootLine(TRUE);
- m_rptTest.SetPageFootFormat("Arial", 16, 0, RGB(255, 0, 0), FALSE, FALSE, FALSE);
- m_rptTest.SetPageFoot("Page Foot: Page 1");
- ShowSomeData();
- }
- void CReportDlg::ShowSomeData()
- {
- m_rptTest.AddRecord("1|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
- m_rptTest.AddRecord("2|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
- m_rptTest.AddRecord("3|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
- m_rptTest.AddRecord("4|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
- m_rptTest.AddRecord("5|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
- m_rptTest.AddRecord("6|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
- m_rptTest.AddRecord("7|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
- m_rptTest.AddRecord("8|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
- m_rptTest.AddRecord("9|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
- m_rptTest.AddRecord("10|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
- m_rptTest.AddRecord("11|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
- m_rptTest.AddRecord("12|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
- m_rptTest.AddRecord("13|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
- m_rptTest.AddRecord("14|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
- m_rptTest.DoPrintPreview();
- }
- void CReportDlg::OnPageheader()
- {
- m_rptTest.Clear();
- m_rptTest.SetColNums(5);
- m_rptTest.SetFixedLeftMargin(50);
- m_rptTest.SetReportTitleHeight(10);
- m_rptTest.SetReportSubTitleHeight(0);
- m_rptTest.SetPageHeadFormat("Arial", 24, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
- m_rptTest.SetPageHead("This is the page header");
- m_rptTest.SetHeadLine(TRUE);
- m_rptTest.SetWidthString("40|100|100|200|200");
- m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
- m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
- ShowSomeData();
- }
- void CReportDlg::OnPagefooter()
- {
- m_rptTest.Clear();
- m_rptTest.SetColNums(5);
- m_rptTest.SetFixedLeftMargin(50);
- m_rptTest.SetPageFootFormat("Arial", 24, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
- m_rptTest.SetPageFoot("This is the page footer");
- m_rptTest.SetFootLine(TRUE);
- m_rptTest.SetWidthString("40|100|100|200|200");
- m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
- m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
- m_rptTest.SetReportHeadHeight(20);
- ShowSomeData();
- }
- void CReportDlg::OnSplitpager()
- {
- m_rptTest.Clear();
- m_rptTest.SetColNums(15);
- m_rptTest.SetFixedLeftMargin(50);
- m_rptTest.SetReportTitleHeight(0);
- m_rptTest.SetReportSubTitleHeight(0);
- m_rptTest.SetWidthString("40|100|100|200|200|100|200|100|200|100|200|100|200|100|200|100");
- m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail|AAAA|BBBB|CCCC|DDDD|EEEE|FFFF|GGGG|HHHH|IIII|JJJJ");
- m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail|AAAA|BBBB|CCCC|DDDD|EEEE|FFFF|GGGG|HHHH|IIII|JJJJ");
- m_rptTest.SetReportHeadHeight(20);
- ShowMoreData();
- }
- void CReportDlg::OnSubtitle()
- {
- m_rptTest.Clear();
- m_rptTest.SetColNums(5);
- m_rptTest.SetFixedLeftMargin(50);
- m_rptTest.SetTitleFormat("Arial", 48, 0, RGB(0, 0, 0), TRUE, TRUE, TRUE);
- m_rptTest.SetReportTitle("This is the title");
- m_rptTest.SetReportSubTitleRowsCols(2, 3);
- m_rptTest.SetReportSubTitleHeight(80);
- m_rptTest.SetSubTitleFormat("Arial", 24, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
- m_rptTest.SetSubTitleAlign(1);
- m_rptTest.SetReportSubTitle("Sub Title 1|Sub Title 2|Sub Title 3|Sub Title 4|Sub Title 5|Sub Title 6");
- m_rptTest.SetWidthString("40|100|100|200|200");
- m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
- m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
- m_rptTest.SetReportHeadHeight(20);
- ShowSomeData();
- }
- void CReportDlg::OnTablebody()
- {
- m_rptTest.Clear();
- m_rptTest.SetColNums(5);
- m_rptTest.SetFixedLeftMargin(50);
- m_rptTest.SetReportTitleHeight(0);
- m_rptTest.SetReportSubTitleHeight(0);
- m_rptTest.SetReportHeadHeight(20);
- m_rptTest.SetWidthString("40|100|100|200|200");
- m_rptTest.SetRecordFormat("Arial", 16, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
- m_rptTest.SetRecordBackColor(RGB(0, 0, 255));
- m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
- m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
- ShowSomeData();
- }
- void CReportDlg::OnTableheader()
- {
- m_rptTest.Clear();
- m_rptTest.SetColNums(5);
- m_rptTest.SetFixedLeftMargin(50);
- m_rptTest.SetReportTitleHeight(0);
- m_rptTest.SetReportSubTitleHeight(0);
- m_rptTest.SetReportHeadHeight(25);
- m_rptTest.SetReportHeadFormat("Arial", 24, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
- m_rptTest.SetReportHeadBackColor(RGB(0, 255, 0));
- m_rptTest.SetWidthString("40|100|100|200|200");
- m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
- m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
- ShowSomeData();
- }
- void CReportDlg::OnTitle()
- {
- m_rptTest.Clear();
- m_rptTest.SetColNums(5);
- m_rptTest.SetFixedLeftMargin(50);
- m_rptTest.SetTitleFormat("Arial", 48, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
- m_rptTest.SetReportTitle("This is the title");
- m_rptTest.SetWidthString("40|100|100|200|200");
- m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
- m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
- m_rptTest.SetReportHeadHeight(20);
- ShowSomeData();
- }
- void CReportDlg::ShowMoreData()
- {
- for(int i = 0; i < 101; i++)
- {
- CString s;
- s.Format("%d|Rose|Male|(324)-3456-7890|Rose@yahoo.com|AAAA|BBBB|CCCC|DDDD|EEEE|FFFF|GGGG|HHHH|IIII|JJJJ", i * 2 + 1);
- m_rptTest.AddRecord(s);
- s.Format("%d|Rose|Male|(324)-3456-7890|Rose@yahoo.com|AAAA|BBBB|CCCC|DDDD|EEEE|FFFF|GGGG|HHHH|IIII|JJJJ", i * 2 + 2);
- m_rptTest.AddRecord(s);
- }
- m_rptTest.DoPrintPreview();
- }
English
