reportDlg.cpp
上传用户:sdomjx
上传日期:2018-09-19
资源大小:12784k
文件大小:12k
源码类别:

浏览器

开发平台:

Visual Basic

  1. // reportDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "report.h"
  5. #include "reportDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CAboutDlg dialog used for App About
  13. class CAboutDlg : public CDialog
  14. {
  15. public:
  16. CAboutDlg();
  17. // Dialog Data
  18. //{{AFX_DATA(CAboutDlg)
  19. enum { IDD = IDD_ABOUTBOX };
  20. //}}AFX_DATA
  21. // ClassWizard generated virtual function overrides
  22. //{{AFX_VIRTUAL(CAboutDlg)
  23. protected:
  24. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  25. //}}AFX_VIRTUAL
  26. // Implementation
  27. protected:
  28. //{{AFX_MSG(CAboutDlg)
  29. //}}AFX_MSG
  30. DECLARE_MESSAGE_MAP()
  31. };
  32. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  33. {
  34. //{{AFX_DATA_INIT(CAboutDlg)
  35. //}}AFX_DATA_INIT
  36. }
  37. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CAboutDlg)
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  44. //{{AFX_MSG_MAP(CAboutDlg)
  45. // No message handlers
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CReportDlg dialog
  50. CReportDlg::CReportDlg(CWnd* pParent /*=NULL*/)
  51. : CDialog(CReportDlg::IDD, pParent)
  52. {
  53. //{{AFX_DATA_INIT(CReportDlg)
  54. // NOTE: the ClassWizard will add member initialization here
  55. //}}AFX_DATA_INIT
  56. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  57. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  58. }
  59. void CReportDlg::DoDataExchange(CDataExchange* pDX)
  60. {
  61. CDialog::DoDataExchange(pDX);
  62. //{{AFX_DATA_MAP(CReportDlg)
  63. DDX_Control(pDX, IDC_REPORTOCXCTRL1, m_rptTest);
  64. //}}AFX_DATA_MAP
  65. }
  66. BEGIN_MESSAGE_MAP(CReportDlg, CDialog)
  67. //{{AFX_MSG_MAP(CReportDlg)
  68. ON_WM_SYSCOMMAND()
  69. ON_WM_PAINT()
  70. ON_WM_QUERYDRAGICON()
  71. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  72. ON_BN_CLICKED(IDC_PAGEHEADER, OnPageheader)
  73. ON_BN_CLICKED(IDC_PAGEFOOTER, OnPagefooter)
  74. ON_BN_CLICKED(IDC_SPLITPAGER, OnSplitpager)
  75. ON_BN_CLICKED(IDC_SUBTITLE, OnSubtitle)
  76. ON_BN_CLICKED(IDC_TABLEBODY, OnTablebody)
  77. ON_BN_CLICKED(IDC_TABLEHEADER, OnTableheader)
  78. ON_BN_CLICKED(IDC_TITLE, OnTitle)
  79. //}}AFX_MSG_MAP
  80. END_MESSAGE_MAP()
  81. /////////////////////////////////////////////////////////////////////////////
  82. // CReportDlg message handlers
  83. BOOL CReportDlg::OnInitDialog()
  84. {
  85. CDialog::OnInitDialog();
  86. // Add "About..." menu item to system menu.
  87. // IDM_ABOUTBOX must be in the system command range.
  88. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  89. ASSERT(IDM_ABOUTBOX < 0xF000);
  90. CMenu* pSysMenu = GetSystemMenu(FALSE);
  91. if (pSysMenu != NULL)
  92. {
  93. CString strAboutMenu;
  94. strAboutMenu.LoadString(IDS_ABOUTBOX);
  95. if (!strAboutMenu.IsEmpty())
  96. {
  97. pSysMenu->AppendMenu(MF_SEPARATOR);
  98. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  99. }
  100. }
  101. // Set the icon for this dialog.  The framework does this automatically
  102. //  when the application's main window is not a dialog
  103. SetIcon(m_hIcon, TRUE); // Set big icon
  104. SetIcon(m_hIcon, FALSE); // Set small icon
  105. // TODO: Add extra initialization here
  106. return TRUE;  // return TRUE  unless you set the focus to a control
  107. }
  108. void CReportDlg::OnSysCommand(UINT nID, LPARAM lParam)
  109. {
  110. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  111. {
  112. CAboutDlg dlgAbout;
  113. dlgAbout.DoModal();
  114. }
  115. else
  116. {
  117. CDialog::OnSysCommand(nID, lParam);
  118. }
  119. }
  120. // If you add a minimize button to your dialog, you will need the code below
  121. //  to draw the icon.  For MFC applications using the document/view model,
  122. //  this is automatically done for you by the framework.
  123. void CReportDlg::OnPaint() 
  124. {
  125. if (IsIconic())
  126. {
  127. CPaintDC dc(this); // device context for painting
  128. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  129. // Center icon in client rectangle
  130. int cxIcon = GetSystemMetrics(SM_CXICON);
  131. int cyIcon = GetSystemMetrics(SM_CYICON);
  132. CRect rect;
  133. GetClientRect(&rect);
  134. int x = (rect.Width() - cxIcon + 1) / 2;
  135. int y = (rect.Height() - cyIcon + 1) / 2;
  136. // Draw the icon
  137. dc.DrawIcon(x, y, m_hIcon);
  138. }
  139. else
  140. {
  141. CDialog::OnPaint();
  142. }
  143. }
  144. // The system calls this to obtain the cursor to display while the user drags
  145. //  the minimized window.
  146. HCURSOR CReportDlg::OnQueryDragIcon()
  147. {
  148. return (HCURSOR) m_hIcon;
  149. }
  150. void CReportDlg::OnButton1() 
  151. {
  152. m_rptTest.Clear();
  153. m_rptTest.SetColNums(5);
  154. m_rptTest.SetFixedLeftMargin(50);
  155. m_rptTest.SetHeadLine(TRUE);
  156. m_rptTest.SetPageHeadFormat("Arial", 16, 0, RGB(0, 0, 255), FALSE, FALSE, FALSE);
  157. m_rptTest.SetPageHead("Page Header: Page 1 2001/12/12");
  158. m_rptTest.SetTitleFormat("Arial", 48, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
  159. m_rptTest.SetReportTitle("Title: This is a test");
  160. m_rptTest.SetSubTitleFormat("Arial", 24, 0, RGB(0, 255, 0), TRUE, TRUE, TRUE);
  161. m_rptTest.SetReportSubTitleRowsCols(1, 2);
  162. m_rptTest.SetReportSubTitle("Manager: Jim Carry|Date: 2001/12/12");
  163. m_rptTest.SetReportHeadHeight(40);
  164.     m_rptTest.SetWidthString("40|100|100|200|200");
  165.         
  166. m_rptTest.SetTopString("NO|Name|Detail|Detail|Detail");
  167.     m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
  168.     m_rptTest.SetRecordFormat("Fixedsys", 0, 0, RGB(255, 0, 0), FALSE, FALSE, FALSE);
  169.         
  170.     m_rptTest.SetRecordBackColor(RGB(0, 255, 0));
  171.     m_rptTest.SetReportHeadBackColor(RGB(255, 0, 255));
  172.         
  173.     m_rptTest.SetGridHeadLineColor(RGB(0, 0, 255));
  174.     m_rptTest.SetGridLineColor(RGB(255, 0, 255));
  175.     
  176. m_rptTest.SetFootLine(TRUE);
  177.        
  178.     m_rptTest.SetPageFootFormat("Arial", 16, 0, RGB(255, 0, 0), FALSE, FALSE, FALSE);
  179.     m_rptTest.SetPageFoot("Page Foot: Page 1");
  180. ShowSomeData();
  181. }
  182. void CReportDlg::ShowSomeData()
  183. {
  184.     m_rptTest.AddRecord("1|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
  185.     m_rptTest.AddRecord("2|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
  186.     m_rptTest.AddRecord("3|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
  187.     m_rptTest.AddRecord("4|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
  188.     m_rptTest.AddRecord("5|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
  189.     m_rptTest.AddRecord("6|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
  190.     m_rptTest.AddRecord("7|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
  191.     m_rptTest.AddRecord("8|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
  192.     m_rptTest.AddRecord("9|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
  193.     m_rptTest.AddRecord("10|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
  194.     m_rptTest.AddRecord("11|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
  195.     m_rptTest.AddRecord("12|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
  196.     m_rptTest.AddRecord("13|Rose|Male|(324)-3456-7890|Rose@yahoo.com");
  197.     m_rptTest.AddRecord("14|Jack|Female|(423)-7890-3456|Jack@microsoft.com");
  198.     m_rptTest.DoPrintPreview();
  199. }
  200. void CReportDlg::OnPageheader() 
  201. {
  202.     m_rptTest.Clear();
  203.     m_rptTest.SetColNums(5);
  204.     m_rptTest.SetFixedLeftMargin(50);
  205.     
  206.     m_rptTest.SetReportTitleHeight(10);
  207.     m_rptTest.SetReportSubTitleHeight(0);
  208.                    
  209.     m_rptTest.SetPageHeadFormat("Arial", 24, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
  210.     m_rptTest.SetPageHead("This is the page header");
  211.     m_rptTest.SetHeadLine(TRUE);
  212.     
  213.     m_rptTest.SetWidthString("40|100|100|200|200");
  214.     
  215.     
  216.     m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
  217.     m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
  218. ShowSomeData();
  219. }
  220. void CReportDlg::OnPagefooter() 
  221. {
  222.     m_rptTest.Clear();
  223.     m_rptTest.SetColNums(5);
  224.     m_rptTest.SetFixedLeftMargin(50);
  225.     
  226.     m_rptTest.SetPageFootFormat("Arial", 24, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
  227.     m_rptTest.SetPageFoot("This is the page footer");
  228.     
  229.     m_rptTest.SetFootLine(TRUE);
  230.     
  231.     m_rptTest.SetWidthString("40|100|100|200|200");
  232.         
  233.     m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
  234.     m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
  235.     m_rptTest.SetReportHeadHeight(20);
  236. ShowSomeData();
  237. }
  238. void CReportDlg::OnSplitpager() 
  239. {
  240.     m_rptTest.Clear();
  241.     m_rptTest.SetColNums(15);
  242.     m_rptTest.SetFixedLeftMargin(50);
  243.     m_rptTest.SetReportTitleHeight(0);
  244.     m_rptTest.SetReportSubTitleHeight(0);
  245.     
  246.     m_rptTest.SetWidthString("40|100|100|200|200|100|200|100|200|100|200|100|200|100|200|100");
  247.             
  248.     m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail|AAAA|BBBB|CCCC|DDDD|EEEE|FFFF|GGGG|HHHH|IIII|JJJJ");
  249.     m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail|AAAA|BBBB|CCCC|DDDD|EEEE|FFFF|GGGG|HHHH|IIII|JJJJ");
  250.     m_rptTest.SetReportHeadHeight(20);
  251.     ShowMoreData();
  252. }
  253. void CReportDlg::OnSubtitle() 
  254. {
  255.     m_rptTest.Clear();
  256.     m_rptTest.SetColNums(5);
  257.     m_rptTest.SetFixedLeftMargin(50);
  258.     
  259.     m_rptTest.SetTitleFormat("Arial", 48, 0, RGB(0, 0, 0), TRUE, TRUE, TRUE);
  260.     m_rptTest.SetReportTitle("This is the title");
  261.     
  262.     m_rptTest.SetReportSubTitleRowsCols(2, 3);
  263.     m_rptTest.SetReportSubTitleHeight(80);
  264.     m_rptTest.SetSubTitleFormat("Arial", 24, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
  265.     m_rptTest.SetSubTitleAlign(1);
  266.     m_rptTest.SetReportSubTitle("Sub Title 1|Sub Title 2|Sub Title 3|Sub Title 4|Sub Title 5|Sub Title 6");
  267.     
  268.     m_rptTest.SetWidthString("40|100|100|200|200");
  269.     
  270.     
  271.     m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
  272.     m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
  273.     m_rptTest.SetReportHeadHeight(20);
  274. ShowSomeData();
  275. }
  276. void CReportDlg::OnTablebody() 
  277. {
  278.     m_rptTest.Clear();
  279.     m_rptTest.SetColNums(5);
  280.     m_rptTest.SetFixedLeftMargin(50);
  281.     
  282.     m_rptTest.SetReportTitleHeight(0);
  283.     m_rptTest.SetReportSubTitleHeight(0);
  284.     
  285.     m_rptTest.SetReportHeadHeight(20);
  286.     m_rptTest.SetWidthString("40|100|100|200|200");
  287.     
  288.     m_rptTest.SetRecordFormat("Arial", 16, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
  289.     m_rptTest.SetRecordBackColor(RGB(0, 0, 255));
  290.             
  291.     m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
  292.     m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
  293. ShowSomeData();
  294. }
  295. void CReportDlg::OnTableheader() 
  296. {
  297.     m_rptTest.Clear();
  298.     m_rptTest.SetColNums(5);
  299.     m_rptTest.SetFixedLeftMargin(50);
  300.     
  301.     m_rptTest.SetReportTitleHeight(0);
  302.     m_rptTest.SetReportSubTitleHeight(0);
  303.     
  304.     m_rptTest.SetReportHeadHeight(25);
  305.     m_rptTest.SetReportHeadFormat("Arial", 24, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
  306.     m_rptTest.SetReportHeadBackColor(RGB(0, 255, 0));
  307.     m_rptTest.SetWidthString("40|100|100|200|200");
  308.     
  309.     
  310.     m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
  311.     m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
  312. ShowSomeData();
  313. }
  314. void CReportDlg::OnTitle() 
  315. {
  316.     m_rptTest.Clear();
  317.     m_rptTest.SetColNums(5);
  318.     m_rptTest.SetFixedLeftMargin(50);
  319.     m_rptTest.SetTitleFormat("Arial", 48, 0, RGB(255, 0, 0), TRUE, TRUE, TRUE);
  320.     m_rptTest.SetReportTitle("This is the title");
  321.     
  322.     m_rptTest.SetWidthString("40|100|100|200|200");
  323.     
  324.     
  325.     m_rptTest.SetTopString("NO|Name|Gender|Telphone|E-mail");
  326.     m_rptTest.SetBottomString("NO|Name|Gender|Telphone|E-mail");
  327.     m_rptTest.SetReportHeadHeight(20);
  328. ShowSomeData();
  329. }
  330. void CReportDlg::ShowMoreData()
  331. {
  332.     for(int i = 0; i < 101; i++)
  333. {
  334. CString s;
  335. s.Format("%d|Rose|Male|(324)-3456-7890|Rose@yahoo.com|AAAA|BBBB|CCCC|DDDD|EEEE|FFFF|GGGG|HHHH|IIII|JJJJ", i * 2 + 1);
  336.         m_rptTest.AddRecord(s);
  337. s.Format("%d|Rose|Male|(324)-3456-7890|Rose@yahoo.com|AAAA|BBBB|CCCC|DDDD|EEEE|FFFF|GGGG|HHHH|IIII|JJJJ", i * 2 + 2);
  338.         m_rptTest.AddRecord(s);
  339. }
  340.     m_rptTest.DoPrintPreview();
  341. }