ReportSampleView.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:57k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // ReportSampleView.cpp : implementation of the CReportSampleView class
  2. //
  3. // This file is a part of the XTREME TOOLKIT PRO MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "ReportSample.h"
  22. #include "MainFrm.h"
  23. #include "ReportSampleDoc.h"
  24. #include "ReportSampleView.h"
  25. #include "ReportMultilinePaintManager.h"
  26. #include "MessageRecord.h"
  27. #include "TreeViewDlg.h"
  28. #include "PerfomanceTestDlg.h"
  29. #include "TaskListView.h"
  30. #include "PropertiesView.h"
  31. #include "HeaderFooterView.h"
  32. #include "float.h"
  33. //#define XML_STATE
  34. #ifdef _DEBUG
  35. #define new DEBUG_NEW
  36. #undef THIS_FILE
  37. static char THIS_FILE[] = __FILE__;
  38. #endif
  39. // Constants used to identify columns, this will be the column ItemIndex
  40. #define COLUMN_IMPORTANCE       0
  41. #define COLUMN_ICON             1
  42. #define COLUMN_ATTACHMENT       2
  43. #define COLUMN_FROM             3
  44. #define COLUMN_SUBJECT          4
  45. #define COLUMN_SENT             5
  46. #define COLUMN_SIZE             6
  47. #define COLUMN_CHECK            7
  48. #define COLUMN_PRICE            8
  49. #define COLUMN_CREATED          9
  50. #define COLUMN_RECEIVED         10
  51. #define COLUMN_CONVERSATION     11
  52. #define COLUMN_CONTACTS         12
  53. #define COLUMN_MESSAGE          13
  54. #define COLUMN_CC               14
  55. #define COLUMN_CATEGORIES       15
  56. #define COLUMN_AUTOFORWARD      16
  57. #define COLUMN_DO_NOT_AUTOARCH  17
  58. #define COLUMN_DUE_BY           18
  59. // Constants used to identify icons used in the ReportControl
  60. #define COLUMN_MAIL_ICON    0
  61. #define COLUMN_CHECK_ICON   2
  62. CString cstrMarkupLongSample(
  63. _T("<StackPanel Margin='5, 5, 5, 5' VerticalAlignment='Top'")
  64. _T("HorizontalAlignment='Center'>")
  65. _T("<TextBlock Padding='0,10,0,0' TextWrapping='Wrap'><Bold>Subject:</Bold> ")
  66. _T("<Bold>SuitePro</Bold> <Run Foreground='Red'>2008</Run> ")
  67. _T("Released!</TextBlock>")
  68. _T("<TextBlock Padding='0,10,0,0'><Bold>Body:</Bold></TextBlock>")
  69. _T("<TextBlock Padding='10,10,0,0' TextWrapping='Wrap'>")
  70. _T("<Bold><Run Foreground='Blue'>Codejock</Run> Software</Bold> released ")
  71. _T("<Bold>SuitePro</Bold> <Run Foreground='Red'>2008</Run> today.  All")
  72. _T(" development machines <Bold>must</Bold> be updated no later than ")
  73. _T("<Run Foreground='Red'>06/15/08</Run>.")
  74. _T("</TextBlock>")
  75. _T("<TextBlock Padding='10,10,0,0'>")
  76. _T("   - Management")
  77. _T("</TextBlock>")
  78. _T("</StackPanel>"));
  79. CString cstrMarkupShortSample(
  80.  _T("<StackPanel VerticalAlignment='Top' HorizontalAlignment='Center'>")
  81.  _T("<TextBlock><Bold>Subject:</Bold> ")
  82.  _T("<Italic>SuitePro</Italic> <Run Foreground='Red'>2008</Run> ")
  83.  _T("Released!</TextBlock>")
  84.  _T("</StackPanel>"));
  85. /////////////////////////////////////////////////////////////////////////////
  86. // CReportSampleView
  87. IMPLEMENT_DYNCREATE(CReportSampleView, CXTPReportView)
  88. BEGIN_MESSAGE_MAP(CReportSampleView, CXTPReportView)
  89. //{{AFX_MSG_MAP(CReportSampleView)
  90. ON_WM_CREATE()
  91. ON_COMMAND(ID_ENABLE_PREVIEW, OnEnablePreview)
  92. ON_UPDATE_COMMAND_UI(ID_ENABLE_PREVIEW, OnUpdateEnablePreview)
  93. ON_COMMAND(ID_TEST_AUTOGROUPING, OnAutoGrouping)
  94. ON_UPDATE_COMMAND_UI(ID_TEST_AUTOGROUPING, OnUpdateAutoGrouping)
  95. ON_COMMAND(ID_TEST_GROUPBY, OnGroupBy)
  96. ON_UPDATE_COMMAND_UI(ID_TEST_GROUPBY, OnUpdateGroupBy)
  97. ON_COMMAND(ID_TEST_MARKUP, OnTestMarkup)
  98. ON_UPDATE_COMMAND_UI(ID_TEST_MARKUP, OnUpdateTestMarkup)
  99. ON_COMMAND(ID_TEST_GROUPSHADE, OnGroupShade)
  100. ON_UPDATE_COMMAND_UI(ID_TEST_GROUPSHADE, OnUpdateGroupShade)
  101. ON_COMMAND(ID_TEST_GROUPSBOLD, OnGroupBold)
  102. ON_UPDATE_COMMAND_UI(ID_TEST_GROUPSBOLD, OnUpdateGroupBold)
  103. ON_COMMAND(ID_TEST_TREEVIEWDIALOG, OnTreeViewDlg)
  104. ON_COMMAND(ID_REPORTCONTROL_AUTOMATICFORMATTINGSAMPLE, OnReportcontrolAutomaticformattingsample)
  105. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_AUTOMATICFORMATTINGSAMPLE, OnUpdateReportcontrolAutomaticformattingsample)
  106. ON_COMMAND(ID_OPTIONS_ALLOWCOLUMNRESIZE, OnOptionsAllowcolumnresize)
  107. ON_UPDATE_COMMAND_UI(ID_OPTIONS_ALLOWCOLUMNRESIZE, OnUpdateOptionsAllowcolumnresize)
  108. ON_COMMAND(ID_OPTIONS_ALLOWCOLUMNSREMOVE, OnOptionsAllowcolumnsremove)
  109. ON_UPDATE_COMMAND_UI(ID_OPTIONS_ALLOWCOLUMNSREMOVE, OnUpdateOptionsAllowcolumnsremove)
  110. ON_COMMAND(ID_OPTIONS_MULTIPLESELECTION, OnOptionsMultipleselection)
  111. ON_UPDATE_COMMAND_UI(ID_OPTIONS_MULTIPLESELECTION, OnUpdateOptionsMultipleselection)
  112. ON_COMMAND(ID_OPTIONS_SHOWITEMSINGROUPS, OnOptionsShowitemsingroups)
  113. ON_UPDATE_COMMAND_UI(ID_OPTIONS_SHOWITEMSINGROUPS, OnUpdateOptionsShowitemsingroups)
  114. ON_WM_SETFOCUS()
  115. ON_WM_DESTROY()
  116. ON_COMMAND(ID_TEST_TASKLIST, OnTestTasklist)
  117. ON_COMMAND(ID_TEST_HEADERFOOTER, OnTestHeaderFooter)
  118. ON_COMMAND(ID_TEST_PERFOMANCE, OnTestPerfomance)
  119. ON_COMMAND(ID_TEST_PROPERTIES, OnTestProperties)
  120. ON_COMMAND(ID_OPTIONS_AUTOMATICCOLUMNSIZING, OnOptionsAutomaticcolumnsizing)
  121. ON_UPDATE_COMMAND_UI(ID_OPTIONS_AUTOMATICCOLUMNSIZING, OnUpdateOptionsAutomaticcolumnsizing)
  122. ON_COMMAND(ID_OPTIONS_FULLCOLUMNSCROLING, OnOptionsFullColumnScrolling)
  123. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FULLCOLUMNSCROLING, OnUpdateOptionsFullColumnScrolling)
  124. ON_COMMAND(ID_REPORTCONTROL_MULTILINESAMPLE, OnReportcontrolMultilinesample)
  125. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_MULTILINESAMPLE, OnUpdateReportcontrolMultilinesample)
  126. ON_COMMAND(ID_REPORTHEADER_ALLOWCOLUMNREORDER, OnReportheaderAllowcolumnreorder)
  127. ON_UPDATE_COMMAND_UI(ID_REPORTHEADER_ALLOWCOLUMNREORDER, OnUpdateReportheaderAllowcolumnreorder)
  128. ON_COMMAND_RANGE(ID_COLUMNSTYLE_SHADED, ID_COLUMNSTYLE_OFFICE2007, OnColumnStyle)
  129. ON_UPDATE_COMMAND_UI_RANGE(ID_COLUMNSTYLE_SHADED, ID_COLUMNSTYLE_OFFICE2007, OnUpdateColumnStyle)
  130. ON_COMMAND(ID_OPTIONS_FREEZECOLUMNS_0, OnOptionsFreezecolumns0)
  131. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FREEZECOLUMNS_0, OnUpdateOptionsFreezecolumns0)
  132. ON_COMMAND(ID_OPTIONS_FREEZECOLUMNS_1, OnOptionsFreezecolumns1)
  133. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FREEZECOLUMNS_1, OnUpdateOptionsFreezecolumns1)
  134. ON_COMMAND(ID_OPTIONS_FREEZECOLUMNS_2, OnOptionsFreezecolumns2)
  135. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FREEZECOLUMNS_2, OnUpdateOptionsFreezecolumns2)
  136. ON_COMMAND(ID_OPTIONS_FREEZECOLUMNS_3, OnOptionsFreezecolumns3)
  137. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FREEZECOLUMNS_3, OnUpdateOptionsFreezecolumns3)
  138. ON_COMMAND(ID_REPORTCONTROL_RIGHTTOLEFT, OnReportcontrolRighttoleft)
  139. ON_UPDATE_COMMAND_UI(ID_REPORTCONTROL_RIGHTTOLEFT, OnUpdateReportcontrolRighttoleft)
  140. ON_COMMAND(ID_OPTIONS_FREEZECOLUMNS_DIVIDER_1, OnOptionsFreezecolumnsDivider1)
  141. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FREEZECOLUMNS_DIVIDER_1, OnUpdateOptionsFreezecolumnsDivider1)
  142. ON_COMMAND(ID_OPTIONS_FREEZECOLUMNS_DIVIDER_2, OnOptionsFreezecolumnsDivider2)
  143. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FREEZECOLUMNS_DIVIDER_2, OnUpdateOptionsFreezecolumnsDivider2)
  144. ON_COMMAND(ID_OPTIONS_FREEZECOLUMNS_DIVIDER_HEADER, OnOptionsFreezecolumnsDividerHeader)
  145. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FREEZECOLUMNS_DIVIDER_HEADER, OnUpdateOptionsFreezecolumnsDividerHeader)
  146. ON_COMMAND(ID_OPTIONS_FREEZECOLUMNS_DIVIDER_NONE, OnOptionsFreezecolumnsDividerNone)
  147. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FREEZECOLUMNS_DIVIDER_NONE, OnUpdateOptionsFreezecolumnsDividerNone)
  148. ON_COMMAND(ID_OPTIONS_FREEZECOLUMNS_DIVIDER_SHADE, OnOptionsFreezecolumnsDividerShade)
  149. ON_UPDATE_COMMAND_UI(ID_OPTIONS_FREEZECOLUMNS_DIVIDER_SHADE, OnUpdateOptionsFreezecolumnsDividerShade)
  150. //}}AFX_MSG_MAP
  151. // Standard printing commands
  152. ON_COMMAND_RANGE(ID_GRID_HORIZONTAL_NOGRIDLINES, ID_GRID_HORIZONTAL_SOLID, OnGridHorizontal)
  153. ON_UPDATE_COMMAND_UI_RANGE(ID_GRID_HORIZONTAL_NOGRIDLINES, ID_GRID_HORIZONTAL_SOLID, OnUpdateGridHorizontal)
  154. ON_COMMAND_RANGE(ID_GRID_VERTICAL_NOGRIDLINES, ID_GRID_VERTICAL_SOLID, OnGridVertical)
  155. ON_UPDATE_COMMAND_UI_RANGE(ID_GRID_VERTICAL_NOGRIDLINES, ID_GRID_VERTICAL_SOLID, OnUpdateGridVertical)
  156. ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  157. ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  158. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  159. ON_COMMAND(ID_FILE_PAGE_SETUP, CXTPReportView::OnFilePageSetup)
  160. ON_NOTIFY(NM_CLICK, XTP_ID_REPORT_CONTROL, OnReportItemClick)
  161. ON_NOTIFY(XTP_NM_REPORT_HYPERLINK , XTP_ID_REPORT_CONTROL, OnReportHyperlinkClick)
  162. ON_NOTIFY(NM_RCLICK, XTP_ID_REPORT_CONTROL, OnReportItemRClick)
  163. ON_NOTIFY(NM_DBLCLK, XTP_ID_REPORT_CONTROL, OnReportItemDblClick)
  164. ON_NOTIFY(XTP_NM_REPORT_HEADER_RCLICK, XTP_ID_REPORT_CONTROL, OnReportColumnRClick)
  165. ON_NOTIFY(NM_KEYDOWN, XTP_ID_REPORT_CONTROL, OnReportKeyDown)
  166. ON_NOTIFY(LVN_BEGINDRAG, XTP_ID_REPORT_CONTROL, OnReportBeginDrag)
  167. ON_NOTIFY(XTP_NM_REPORT_BEFORE_PASTE_FROMTEXT, XTP_ID_REPORT_CONTROL, OnReportBeforePasteFromText)
  168. END_MESSAGE_MAP()
  169. /////////////////////////////////////////////////////////////////////////////
  170. // CReportSampleView construction/destruction
  171. CReportSampleView::CReportSampleView()
  172. {
  173. m_bAutomaticFormating = FALSE;
  174. m_pTaskFrame = 0;
  175. m_pHeaderFooterFrame = 0;
  176. m_pPropertiesFrame = 0;
  177. m_bMultilineSample = FALSE;
  178. }
  179. CReportSampleView::~CReportSampleView()
  180. {
  181. }
  182. BOOL CReportSampleView::PreCreateWindow(CREATESTRUCT& cs)
  183. {
  184. if (!CView::PreCreateWindow(cs))
  185. return FALSE;
  186. //cs.dwExStyle |= WS_EX_STATICEDGE;
  187. cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
  188. return TRUE;
  189. }
  190. /////////////////////////////////////////////////////////////////////////////
  191. // CReportSampleView diagnostics
  192. #ifdef _DEBUG
  193. void CReportSampleView::AssertValid() const
  194. {
  195. CView::AssertValid();
  196. }
  197. void CReportSampleView::Dump(CDumpContext& dc) const
  198. {
  199. CView::Dump(dc);
  200. }
  201. CReportSampleDoc* CReportSampleView::GetDocument() // non-debug version is inline
  202. {
  203. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CReportSampleDoc)));
  204. return (CReportSampleDoc*)m_pDocument;
  205. }
  206. #endif //_DEBUG
  207. /////////////////////////////////////////////////////////////////////////////
  208. // CReportSampleView message handlers
  209. int CReportSampleView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  210. {
  211. if (CXTPReportView::OnCreate(lpCreateStruct) == -1)
  212. return -1;
  213. VERIFY(m_ilIcons.Create(16,16, ILC_COLOR24|ILC_MASK, 0, 1));
  214. CBitmap bmp;
  215. VERIFY(bmp.LoadBitmap(IDB_BMREPORT));
  216. m_ilIcons.Add(&bmp, RGB(255, 0, 255));
  217. CXTPReportControl& wndReport = GetReportCtrl();
  218. wndReport.SetImageList(&m_ilIcons);
  219. //
  220. //  Add sample columns
  221. //
  222. wndReport.AddColumn(new CXTPReportColumn(COLUMN_IMPORTANCE, _T("Importance"), 18, FALSE, 1));
  223. wndReport.AddColumn(new CXTPReportColumn(COLUMN_ICON, _T("Message Class"), 18, FALSE, COLUMN_MAIL_ICON));
  224. wndReport.AddColumn(new CXTPReportColumn(COLUMN_ATTACHMENT, _T("Attachment"), 18, FALSE, 7));
  225. wndReport.AddColumn(new CXTPReportColumn(COLUMN_FROM, _T("From"), 100));
  226. wndReport.AddColumn(new CXTPReportColumn(COLUMN_SUBJECT, _T("Subject"), 180));
  227. wndReport.AddColumn(new CXTPReportColumn(COLUMN_RECEIVED, _T("Received"), 80));
  228. wndReport.AddColumn(new CXTPReportColumn(COLUMN_SIZE, _T("Size"), 55, FALSE));
  229. wndReport.AddColumn(new CXTPReportColumn(COLUMN_CHECK, _T("Checked"), 18, FALSE, COLUMN_CHECK_ICON));
  230. wndReport.AddColumn(new CXTPReportColumn(COLUMN_PRICE, _T("Price"), 80, TRUE, XTP_REPORT_NOICON, TRUE, FALSE));
  231. wndReport.AddColumn(new CXTPReportColumn(COLUMN_SENT, _T("Sent"), 150, TRUE, XTP_REPORT_NOICON, TRUE, FALSE));
  232. wndReport.AddColumn(new CXTPReportColumn(COLUMN_CREATED, _T("Created"), 80, TRUE, XTP_REPORT_NOICON, TRUE, FALSE));
  233. wndReport.AddColumn(new CXTPReportColumn(COLUMN_CONVERSATION, _T("Conversation"), 30, TRUE, XTP_REPORT_NOICON, TRUE, FALSE));
  234. wndReport.AddColumn(new CXTPReportColumn(COLUMN_CONTACTS, _T("Contacts"), 30, TRUE, XTP_REPORT_NOICON, TRUE, FALSE));
  235. wndReport.AddColumn(new CXTPReportColumn(COLUMN_MESSAGE, _T("Message"), 80, TRUE, XTP_REPORT_NOICON, TRUE, FALSE));
  236. wndReport.AddColumn(new CXTPReportColumn(COLUMN_CC, _T("CC"), 80, TRUE, XTP_REPORT_NOICON, TRUE, FALSE));
  237. wndReport.AddColumn(new CXTPReportColumn(COLUMN_CATEGORIES, _T("Categories"), 30, TRUE, XTP_REPORT_NOICON, TRUE, FALSE));
  238. wndReport.AddColumn(new CXTPReportColumn(COLUMN_AUTOFORWARD, _T("Auto Forward"), 30, TRUE, XTP_REPORT_NOICON, TRUE, FALSE));
  239. wndReport.AddColumn(new CXTPReportColumn(COLUMN_DO_NOT_AUTOARCH, _T("Do not autoarchive"), 30, TRUE, XTP_REPORT_NOICON, TRUE, FALSE));
  240. wndReport.AddColumn(new CXTPReportColumn(COLUMN_DUE_BY, _T("Due by"), 30, TRUE, XTP_REPORT_NOICON, TRUE, FALSE));
  241. //
  242. //  Add sample records
  243. //
  244. AddSampleRecords();
  245. // add sample hyperlinks
  246. //wndReport.GetRecords()->GetAt(6)->GetItem(COLUMN_FROM)->AddHyperlink(new CXTPReportHyperlink(7, 14));
  247. wndReport.GetRecords()->GetAt(3)->GetItem(COLUMN_FROM)->AddHyperlink(new CXTPReportHyperlink(12, 26));
  248. ((CXTPReportRecordItem*)(wndReport.GetRecords()->GetAt(3)->GetItemPreview()))->AddHyperlink(new CXTPReportHyperlink(27, 7));
  249. ((CXTPReportRecordItem*)(wndReport.GetRecords()->GetAt(3)->GetItemPreview()))->AddHyperlink(new CXTPReportHyperlink(110, 13));
  250. ((CXTPReportRecordItem*)(wndReport.GetRecords()->GetAt(5)->GetItemPreview()))->AddHyperlink(new CXTPReportHyperlink(21, 26));
  251. ((CXTPReportRecordItem*)(wndReport.GetRecords()->GetAt(5)->GetItemPreview()))->AddHyperlink(new CXTPReportHyperlink(123, 26));
  252. wndReport.GetRecords()->GetAt(8)->GetItem(COLUMN_FROM)->AddHyperlink(new CXTPReportHyperlink(0, 28));
  253. wndReport.GetRecords()->GetAt(3)->SetEditable(FALSE);
  254. OnGroupBy();
  255. OnAutoGrouping();
  256. wndReport.Populate();
  257. LoadReportState();
  258. wndReport.EnableDragDrop(_T("ReportSampleView"), xtpReportAllowDrag | xtpReportAllowDrop);
  259. m_wndReport.GetPaintManager()->SetColumnStyle(xtpReportColumnOffice2007);
  260. m_wndScrollBar.Create(WS_CHILD | WS_VISIBLE | SBS_VERT, CRect(0, 0, 0, 0), this, 100);
  261. m_wndScrollBar.SetScrollBarStyle(xtpScrollStyleOffice2007Dark);
  262. SetScrollBarCtrl(&m_wndScrollBar);
  263. return 0;
  264. }
  265. // Before self destroying destroy all child forms 
  266. void CReportSampleView::OnDestroy()
  267. {
  268. SaveReportState();
  269. if (m_pTaskFrame)
  270. {
  271. m_pTaskFrame->DestroyWindow();
  272. }
  273. if (m_pPropertiesFrame)
  274. {
  275. m_pPropertiesFrame->DestroyWindow();
  276. }
  277. if (m_pHeaderFooterFrame)
  278. {
  279. m_pHeaderFooterFrame->DestroyWindow();
  280. }
  281. CView::OnDestroy();
  282. }
  283. // Preview is a text message which is shown for every row, 
  284. // if ReportControl is in Preview mode.
  285. // In this sample preview text is equal to Message text, 
  286. // but it doesn't have to be always used in such way 
  287. void CReportSampleView::OnEnablePreview()
  288. {
  289. GetReportCtrl().EnablePreviewMode(!GetReportCtrl().IsPreviewMode());
  290. GetReportCtrl().Populate();
  291. }
  292. void CReportSampleView::OnUpdateEnablePreview(CCmdUI* pCmdUI)
  293. {
  294. pCmdUI->SetCheck(GetReportCtrl().IsPreviewMode());
  295. }
  296. void CReportSampleView::OnGroupBy()
  297. {
  298. GetReportCtrl().ShowGroupBy(!GetReportCtrl().IsGroupByVisible());
  299. }
  300. void CReportSampleView::OnUpdateGroupBy(CCmdUI* pCmdUI)
  301. {
  302. pCmdUI->SetCheck(GetReportCtrl().IsGroupByVisible());
  303. }
  304. void CReportSampleView::OnTestMarkup()
  305. {
  306. GetReportCtrl().EnableMarkup(!GetReportCtrl().GetMarkupContext());
  307. if (GetReportCtrl().GetMarkupContext())
  308. {
  309. GetReportCtrl().GetColumns()->GetAt(COLUMN_SUBJECT)->SetCaption(cstrMarkupShortSample);
  310. GetReportCtrl().GetRecords()->GetAt(9)->GetItem(COLUMN_SUBJECT)->SetCaption(cstrMarkupShortSample);
  311. GetReportCtrl().GetRecords()->GetAt(9)->GetItemPreview()->SetCaption(cstrMarkupLongSample);
  312. GetReportCtrl().RedrawControl();
  313. }
  314. }
  315. void CReportSampleView::OnUpdateTestMarkup(CCmdUI* pCmdUI)
  316. {
  317. pCmdUI->SetCheck(GetReportCtrl().GetMarkupContext() != NULL);
  318. }
  319. // Toggles shady style for group heading
  320. void CReportSampleView::OnGroupShade()
  321. {
  322. GetReportCtrl().ShadeGroupHeadings(!GetReportCtrl().IsShadeGroupHeadingsEnabled());
  323. }
  324. void CReportSampleView::OnUpdateGroupShade(CCmdUI* pCmdUI)
  325. {
  326. pCmdUI->SetCheck(GetReportCtrl().IsShadeGroupHeadingsEnabled());
  327. }
  328. // Toggles bold style for group heading
  329. void CReportSampleView::OnGroupBold()
  330. {
  331. GetReportCtrl().SetGroupRowsBold(!GetReportCtrl().IsGroupRowsBold());
  332. GetReportCtrl().RedrawControl();
  333. }
  334. void CReportSampleView::OnUpdateGroupBold(CCmdUI* pCmdUI)
  335. {
  336. pCmdUI->SetCheck(GetReportCtrl().IsGroupRowsBold());
  337. }
  338. void CReportSampleView::OnAutoGrouping()
  339. {
  340. if (GetReportCtrl().GetColumns()->GetGroupsOrder()->GetCount() == 0)
  341. {
  342. CXTPReportColumn* pColFrom = GetReportCtrl().GetColumns()->Find(COLUMN_FROM);
  343. GetReportCtrl().GetColumns()->GetGroupsOrder()->Clear();
  344. GetReportCtrl().GetColumns()->GetGroupsOrder()->Add(pColFrom);
  345. }
  346. else
  347. {
  348. GetReportCtrl().GetColumns()->GetGroupsOrder()->Clear();
  349. }
  350. GetReportCtrl().Populate();
  351. }
  352. void CReportSampleView::OnUpdateAutoGrouping(CCmdUI* pCmdUI)
  353. {
  354. pCmdUI->SetCheck(GetReportCtrl().GetColumns()->GetGroupsOrder()->GetCount() > 0);
  355. }
  356. void CReportSampleView::OnInitialUpdate()
  357. {
  358. CView::OnInitialUpdate();
  359. CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd();
  360. if (m_wndSubList.GetSafeHwnd() == NULL)
  361. {
  362. m_wndSubList.SubclassDlgItem(IDC_COLUMNLIST, &pWnd->m_wndFieldChooser);
  363. GetReportCtrl().GetColumns()->GetReportHeader()->SetSubListCtrl(&m_wndSubList);
  364. }
  365. if (m_wndFilterEdit.GetSafeHwnd() == NULL)
  366. {
  367. m_wndFilterEdit.SubclassDlgItem(IDC_FILTEREDIT, &pWnd->m_wndFilterEdit);
  368. GetReportCtrl().GetColumns()->GetReportHeader()->SetFilterEditCtrl(&m_wndFilterEdit);
  369. }
  370. }
  371. void CReportSampleView::LoadReportState()
  372. {
  373. #ifdef XML_STATE
  374. CXTPPropExchangeXMLNode px(TRUE, 0, _T("ReportControl"));
  375. if (!px.LoadFromFile(_T("c:\ReportControl.xml")))
  376. return;
  377. GetReportCtrl().DoPropExchange(&px);
  378. CXTPPropExchangeSection secOthers(px.GetSection(_T("Others")));
  379. BOOL bMultilineSample = FALSE;
  380. PX_Bool(&secOthers, _T("MultilineSample"), bMultilineSample, FALSE);
  381. m_bMultilineSample = !bMultilineSample;
  382. OnReportcontrolMultilinesample();
  383. #else
  384. UINT nBytes = 0;
  385. LPBYTE pData = 0;
  386. if (!AfxGetApp()->GetProfileBinary(_T("ReportControl"), _T("State"), &pData, &nBytes))
  387. return;
  388. CMemFile memFile(pData, nBytes);
  389. CArchive ar (&memFile,CArchive::load);
  390. try
  391. {
  392. GetReportCtrl().SerializeState(ar);
  393. }
  394. catch (COleException* pEx)
  395. {
  396. pEx->Delete ();
  397. }
  398. catch (CArchiveException* pEx)
  399. {
  400. pEx->Delete ();
  401. }
  402. ar.Close();
  403. memFile.Close();
  404. delete[] pData;
  405. // others
  406. m_bMultilineSample = !AfxGetApp()->GetProfileInt(_T("ReportControl"), _T("MultilineSample"), 0);
  407. OnReportcontrolMultilinesample();
  408. #endif
  409. }
  410. void CReportSampleView::SaveReportState()
  411. {
  412. #ifdef XML_STATE
  413. CXTPPropExchangeXMLNode px(FALSE, 0, _T("ReportControl"));
  414. GetReportCtrl().DoPropExchange(&px);
  415. CXTPPropExchangeSection secOthers(px.GetSection(_T("Others")));
  416. BOOL bMultilineSample = m_bMultilineSample;
  417. PX_Bool(&secOthers, _T("MultilineSample"), bMultilineSample, FALSE);
  418. // Save All Records
  419. //CXTPPropExchangeSection secRecords(px.GetSection(_T("Records")));
  420. //GetReportCtrl().GetRecords()->DoPropExchange(&secRecords);
  421. px.SaveToFile(_T("c:\ReportControl.xml"));
  422. #else
  423. CMemFile memFile;
  424. CArchive ar (&memFile,CArchive::store);
  425. GetReportCtrl().SerializeState(ar);
  426. ar.Flush();
  427. DWORD nBytes = (DWORD)memFile.GetPosition();
  428. LPBYTE pData = memFile.Detach();
  429. AfxGetApp()->WriteProfileBinary(_T("ReportControl"), _T("State"), pData, nBytes);
  430. ar.Close();
  431. memFile.Close();
  432. free(pData);
  433. AfxGetApp()->WriteProfileInt(_T("ReportControl"), _T("MultilineSample"), m_bMultilineSample);
  434. #endif
  435. }
  436. #define ID_REMOVE_ITEM  1
  437. #define ID_SORT_ASC     2
  438. #define ID_SORT_DESC        3
  439. #define ID_SORT_NO      99
  440. #define ID_GROUP_BYTHIS 4
  441. #define ID_SHOW_GROUPBOX        5
  442. #define ID_SHOW_FIELDCHOOSER 6
  443. #define ID_COLUMN_BESTFIT       7
  444. #define ID_COLUMN_ARRANGEBY 100
  445. #define ID_COLUMN_ALIGMENT  200
  446. #define ID_COLUMN_ALIGMENT_TEXT  210
  447. #define ID_COLUMN_ALIGMENT_LEFT   211
  448. #define ID_COLUMN_ALIGMENT_RIGHT  212
  449. #define ID_COLUMN_ALIGMENT_CENTER 213
  450. #define ID_COLUMN_ALIGMENT_ICON  220
  451. #define ID_COLUMN_ICON_ALIGMENT_LEFT   221
  452. #define ID_COLUMN_ICON_ALIGMENT_RIGHT  222
  453. #define ID_COLUMN_ICON_ALIGMENT_CENTER 223
  454. #define ID_COLUMN_SHOW      500
  455. CString LoadResourceString(UINT nID)
  456. {
  457. CString str;
  458. VERIFY(str.LoadString(nID));
  459. return str;
  460. }
  461. // When user does a right click on column header, generate popup menu
  462. // Procedure contains handlers of pressing all buttons in popup menu
  463. void CReportSampleView::OnReportColumnRClick(NMHDR * pNotifyStruct, LRESULT * /*result*/)
  464. {
  465. XTP_NM_REPORTRECORDITEM* pItemNotify = (XTP_NM_REPORTRECORDITEM*) pNotifyStruct;
  466. ASSERT(pItemNotify->pColumn);
  467. CPoint ptClick = pItemNotify->pt;
  468. CMenu menu;
  469. VERIFY(menu.CreatePopupMenu());
  470. // create main menu items
  471. menu.AppendMenu(MF_STRING, ID_SORT_ASC, LoadResourceString(IDS_SORTASC));
  472. menu.AppendMenu(MF_STRING, ID_SORT_DESC, LoadResourceString(IDS_SORTDESC));
  473. menu.AppendMenu(MF_STRING, ID_SORT_NO, LoadResourceString(IDS_SORT_NO));
  474. menu.AppendMenu(MF_SEPARATOR, (UINT)-1, (LPCTSTR)NULL);
  475. menu.AppendMenu(MF_STRING, ID_GROUP_BYTHIS, LoadResourceString(IDS_GROUPBYFIELD));
  476. menu.AppendMenu(MF_STRING, ID_SHOW_GROUPBOX, LoadResourceString(IDS_GROUPBYBOX));
  477. menu.AppendMenu(MF_SEPARATOR, (UINT)-1, (LPCTSTR)NULL);
  478. menu.AppendMenu(MF_STRING, ID_REMOVE_ITEM, LoadResourceString(IDS_REMOVECOL));
  479. menu.AppendMenu(MF_STRING, ID_SHOW_FIELDCHOOSER, LoadResourceString(IDS_FIELDCHOOSER));
  480. menu.AppendMenu(MF_SEPARATOR, (UINT)-1, (LPCTSTR)NULL);
  481. menu.AppendMenu(MF_STRING, ID_COLUMN_BESTFIT, LoadResourceString(IDS_BESTFIT));
  482. if (GetReportCtrl().IsGroupByVisible())
  483. {
  484. menu.CheckMenuItem(ID_SHOW_GROUPBOX, MF_BYCOMMAND|MF_CHECKED);
  485. }
  486. if (GetReportCtrl().GetReportHeader()->IsShowItemsInGroups())
  487. {
  488. menu.EnableMenuItem(ID_GROUP_BYTHIS, MF_BYCOMMAND|MF_DISABLED);
  489. }
  490. CXTPReportColumns* pColumns = GetReportCtrl().GetColumns();
  491. CXTPReportColumn* pColumn = pItemNotify->pColumn;
  492. // create arrange by items
  493. CMenu menuArrange;
  494. VERIFY(menuArrange.CreatePopupMenu());
  495. int nColumnCount = pColumns->GetCount();
  496. int nColumn;
  497. for (nColumn = 0; nColumn < nColumnCount; nColumn++)
  498. {
  499. CXTPReportColumn* pCol = pColumns->GetAt(nColumn);
  500. if (pCol && pCol->IsVisible())
  501. {
  502. CString sCaption = pCol->GetCaption();
  503. if (!sCaption.IsEmpty())
  504. menuArrange.AppendMenu(MF_STRING, ID_COLUMN_ARRANGEBY + nColumn, sCaption);
  505. }
  506. }
  507. menuArrange.AppendMenu(MF_SEPARATOR, 60, (LPCTSTR)NULL);
  508. menuArrange.AppendMenu(MF_STRING, ID_COLUMN_ARRANGEBY + nColumnCount,
  509. LoadResourceString(IDS_SHOWINGROUPS));
  510. menuArrange.CheckMenuItem(ID_COLUMN_ARRANGEBY + nColumnCount,
  511. MF_BYCOMMAND | ((GetReportCtrl().GetReportHeader()->IsShowItemsInGroups()) ? MF_CHECKED : MF_UNCHECKED)  );
  512. menu.InsertMenu(0, MF_BYPOSITION | MF_POPUP, (UINT_PTR) menuArrange.m_hMenu,
  513. LoadResourceString(IDS_ARRANGEBY));
  514. // create columns items
  515. CMenu menuColumns;
  516. VERIFY(menuColumns.CreatePopupMenu());
  517. for (nColumn = 0; nColumn < nColumnCount; nColumn++)
  518. {
  519. CXTPReportColumn* pCol = pColumns->GetAt(nColumn);
  520. CString sCaption = pCol->GetCaption();
  521. //if (!sCaption.IsEmpty())
  522. menuColumns.AppendMenu(MF_STRING, ID_COLUMN_SHOW + nColumn, sCaption);
  523. menuColumns.CheckMenuItem(ID_COLUMN_SHOW + nColumn,
  524. MF_BYCOMMAND | (pCol->IsVisible() ? MF_CHECKED : MF_UNCHECKED) );
  525. }
  526. menu.InsertMenu(0, MF_BYPOSITION | MF_POPUP, (UINT_PTR) menuColumns.m_hMenu,
  527. LoadResourceString(IDS_COLUMNS));
  528. // create alignment submenu
  529. CMenu menuAlign;
  530. VERIFY(menuAlign.CreatePopupMenu());
  531. ////  create Text alignment menu
  532. CMenu menuAlignText;
  533. VERIFY(menuAlignText.CreatePopupMenu());
  534. menuAlignText.AppendMenu(MF_STRING, ID_COLUMN_ALIGMENT_LEFT,
  535. LoadResourceString(IDS_ALIGNLEFT));
  536. menuAlignText.AppendMenu(MF_STRING, ID_COLUMN_ALIGMENT_RIGHT,
  537. LoadResourceString(IDS_ALIGNRIGHT));
  538. menuAlignText.AppendMenu(MF_STRING, ID_COLUMN_ALIGMENT_CENTER,
  539. LoadResourceString(IDS_ALIGNCENTER));
  540. int nAlignOption = 0;
  541. switch (pColumn->GetAlignment() & xtpColumnTextMask)
  542. {
  543. case xtpColumnTextLeft:
  544. nAlignOption = ID_COLUMN_ALIGMENT_LEFT;
  545. break;
  546. case xtpColumnTextRight:
  547. nAlignOption = ID_COLUMN_ALIGMENT_RIGHT;
  548. break;
  549. case xtpColumnTextCenter:
  550. nAlignOption = ID_COLUMN_ALIGMENT_CENTER;
  551. break;
  552. }
  553. menuAlignText.CheckMenuItem(nAlignOption, MF_BYCOMMAND | MF_CHECKED);
  554. menuAlign.InsertMenu(1, MF_BYPOSITION | MF_POPUP, (UINT_PTR) menuAlignText.m_hMenu,
  555. LoadResourceString(IDS_TEXT));
  556. ////  create Icon alignment menu
  557. CMenu menuAlignIcon;
  558. VERIFY(menuAlignIcon.CreatePopupMenu());
  559. menuAlignIcon.AppendMenu(MF_STRING, ID_COLUMN_ICON_ALIGMENT_LEFT,
  560. LoadResourceString(IDS_ALIGNLEFT));
  561. menuAlignIcon.AppendMenu(MF_STRING, ID_COLUMN_ICON_ALIGMENT_RIGHT,
  562. LoadResourceString(IDS_ALIGNRIGHT));
  563. menuAlignIcon.AppendMenu(MF_STRING, ID_COLUMN_ICON_ALIGMENT_CENTER,
  564. LoadResourceString(IDS_ALIGNCENTER));
  565. nAlignOption = 0;
  566. switch (pColumn->GetAlignment() & xtpColumnIconMask)
  567. {
  568. case xtpColumnIconLeft:
  569. nAlignOption = ID_COLUMN_ICON_ALIGMENT_LEFT;
  570. break;
  571. case xtpColumnIconRight:
  572. nAlignOption = ID_COLUMN_ICON_ALIGMENT_RIGHT;
  573. break;
  574. case xtpColumnIconCenter:
  575. nAlignOption = ID_COLUMN_ICON_ALIGMENT_CENTER;
  576. break;
  577. }
  578. menuAlignIcon.CheckMenuItem(nAlignOption, MF_BYCOMMAND | MF_CHECKED);
  579. menuAlign.InsertMenu(2, MF_BYPOSITION | MF_POPUP, (UINT_PTR) menuAlignIcon.m_hMenu,
  580. LoadResourceString(IDS_ICON));
  581. ///
  582. menu.InsertMenu(11, MF_BYPOSITION | MF_POPUP, (UINT_PTR) menuAlign.m_hMenu,
  583. LoadResourceString(IDS_ALIGNMENT));
  584. // track menu
  585. int nMenuResult = CXTPCommandBars::TrackPopupMenu(&menu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTALIGN |TPM_RIGHTBUTTON, ptClick.x, ptClick.y, this, NULL);
  586. // arrange by items
  587. if (nMenuResult >= ID_COLUMN_ARRANGEBY && nMenuResult < ID_COLUMN_ALIGMENT)
  588. {
  589. for (int nColumn = 0; nColumn < nColumnCount; nColumn++)
  590. {
  591. CXTPReportColumn* pCol = pColumns->GetAt(nColumn);
  592. if (pCol && pCol->IsVisible())
  593. {
  594. if (nMenuResult == ID_COLUMN_ARRANGEBY + nColumn)
  595. {
  596. nMenuResult = ID_SORT_ASC;
  597. pColumn = pCol;
  598. break;
  599. }
  600. }
  601. }
  602. // group by item
  603. if (ID_COLUMN_ARRANGEBY + nColumnCount == nMenuResult)
  604. {
  605. GetReportCtrl().GetReportHeader()->ShowItemsInGroups(
  606. !GetReportCtrl().GetReportHeader()->IsShowItemsInGroups());
  607. }
  608. }
  609. // process Alignment options
  610. if (nMenuResult > ID_COLUMN_ALIGMENT_TEXT && nMenuResult < ID_COLUMN_ALIGMENT_ICON)
  611. {
  612. int nAlign = pColumn->GetAlignment();
  613. nAlign &= ~(xtpColumnTextLeft | xtpColumnTextCenter | xtpColumnTextRight);
  614. switch (nMenuResult)
  615. {
  616. case ID_COLUMN_ALIGMENT_LEFT :
  617. pColumn->SetAlignment(nAlign | xtpColumnTextLeft);
  618. break;
  619. case ID_COLUMN_ALIGMENT_RIGHT :
  620. pColumn->SetAlignment(nAlign | xtpColumnTextRight);
  621. break;
  622. case ID_COLUMN_ALIGMENT_CENTER  :
  623. pColumn->SetAlignment(nAlign | xtpColumnTextCenter);
  624. break;
  625. }
  626. }
  627. // process Alignment options
  628. if (nMenuResult > ID_COLUMN_ALIGMENT_ICON && nMenuResult < ID_COLUMN_SHOW)
  629. {
  630. int nAlign = pColumn->GetAlignment();
  631. nAlign &= ~(xtpColumnIconLeft | xtpColumnIconCenter | xtpColumnIconRight);
  632. switch (nMenuResult)
  633. {
  634. case ID_COLUMN_ICON_ALIGMENT_LEFT:
  635. pColumn->SetAlignment(nAlign | xtpColumnIconLeft);
  636. break;
  637. case ID_COLUMN_ICON_ALIGMENT_RIGHT:
  638. pColumn->SetAlignment(nAlign | xtpColumnIconRight);
  639. break;
  640. case ID_COLUMN_ICON_ALIGMENT_CENTER:
  641. pColumn->SetAlignment(nAlign | xtpColumnIconCenter);
  642. break;
  643. }
  644. }
  645. // process column selection item
  646. if (nMenuResult >= ID_COLUMN_SHOW)
  647. {
  648. CXTPReportColumn* pCol = pColumns->GetAt(nMenuResult - ID_COLUMN_SHOW);
  649. if (pCol)
  650. {
  651. pCol->SetVisible(!pCol->IsVisible());
  652. }
  653. }
  654. // other general items
  655. switch (nMenuResult)
  656. {
  657. case ID_REMOVE_ITEM:
  658. pColumn->SetVisible(FALSE);
  659. GetReportCtrl().Populate();
  660. break;
  661. case ID_SORT_ASC:
  662. case ID_SORT_DESC:
  663. if (pColumn && pColumn->IsSortable())
  664. {
  665. pColumns->SetSortColumn(pColumn, nMenuResult == ID_SORT_ASC);
  666. GetReportCtrl().Populate();
  667. }
  668. break;
  669. case ID_SORT_NO:
  670. pColumns->GetSortOrder()->Clear();
  671. break;
  672. case ID_GROUP_BYTHIS:
  673. if (pColumns->GetGroupsOrder()->IndexOf(pColumn) < 0)
  674. {
  675. pColumns->GetGroupsOrder()->Add(pColumn);
  676. }
  677. GetReportCtrl().ShowGroupBy(TRUE);
  678. GetReportCtrl().Populate();
  679. break;
  680. case ID_SHOW_GROUPBOX:
  681. GetReportCtrl().ShowGroupBy(!GetReportCtrl().IsGroupByVisible());
  682. break;
  683. case ID_SHOW_FIELDCHOOSER:
  684. OnShowFieldChooser();
  685. break;
  686. case ID_COLUMN_BESTFIT:
  687. GetReportCtrl().GetColumns()->GetReportHeader()->BestFit(pColumn);
  688. break;
  689. }
  690. }
  691. void CReportSampleView::OnReportBeginDrag(NMHDR * /*pNotifyStruct*/, LRESULT * /*result*/)
  692. {
  693. }
  694. // When user does a right click on row with a group name, generate popup menu
  695. // Procedure contains handlers of pressing all buttons in popup menu
  696. void CReportSampleView::OnReportItemRClick(NMHDR * pNotifyStruct, LRESULT * /*result*/)
  697. {
  698. XTP_NM_REPORTRECORDITEM* pItemNotify = (XTP_NM_REPORTRECORDITEM*) pNotifyStruct;
  699. if (!pItemNotify->pRow)
  700. return;
  701. if (pItemNotify->pRow->IsGroupRow())
  702. {
  703. CMenu menu;
  704. VERIFY(menu.LoadMenu(IDR_MENU_CONTEXT_GROUP));
  705. // track menu
  706. int nMenuResult = CXTPCommandBars::TrackPopupMenu(menu.GetSubMenu(0), TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTALIGN |TPM_RIGHTBUTTON, pItemNotify->pt.x, pItemNotify->pt.y, this, NULL);
  707. // general items processing
  708. switch (nMenuResult)
  709. {
  710. case ID_POPUP_COLLAPSEALLGROUPS:
  711. pItemNotify->pRow->GetControl()->CollapseAll();
  712. break;
  713. case ID_POPUP_EXPANDALLGROUPS:
  714. pItemNotify->pRow->GetControl()->ExpandAll();
  715. break;
  716. }
  717. } else
  718. {
  719. }
  720. }
  721. // Set reaction on clicking hyperlink in some of ReportControl cells
  722. void CReportSampleView::OnReportHyperlinkClick(NMHDR * pNotifyStruct, LRESULT * /*result*/)
  723. {
  724. XTP_NM_REPORTRECORDITEM* pItemNotify = (XTP_NM_REPORTRECORDITEM*) pNotifyStruct;
  725. if (!pItemNotify->pRow || !pItemNotify->pColumn)
  726. return;
  727. // if click on Hyperlink in Item
  728. if (pItemNotify->nHyperlink >= 0)
  729. TRACE(_T("Hyperlink Click : n row %d n col %d n Hyperlink %dn"),
  730. pItemNotify->pRow->GetIndex(), pItemNotify->pColumn->GetItemIndex(), pItemNotify->nHyperlink);
  731. }
  732. // Handles clicking ReportControl row.
  733. // If "Checked" item is clicked, change "Checked" attribute for current record
  734. void CReportSampleView::OnReportItemClick(NMHDR * pNotifyStruct, LRESULT * /*result*/)
  735. {
  736. XTP_NM_REPORTRECORDITEM* pItemNotify = (XTP_NM_REPORTRECORDITEM*) pNotifyStruct;
  737. if (!pItemNotify->pRow || !pItemNotify->pColumn)
  738. return;
  739. TRACE(_T("Click on row %d, col %dn"),
  740. pItemNotify->pRow->GetIndex(), pItemNotify->pColumn->GetItemIndex());
  741. if (pItemNotify->pColumn->GetItemIndex() == COLUMN_CHECK)
  742. {
  743. GetReportCtrl().Populate();
  744. }
  745. }
  746. // Handles key pressing. If pressed key is RETURN, then change "Read" attribute
  747. // of current record to True.
  748. // Keys like Up/Down are handled by the control itself with the
  749. // default behavior.
  750. void CReportSampleView::OnReportKeyDown(NMHDR * pNotifyStruct, LRESULT * /*result*/)
  751. {
  752. LPNMKEY lpNMKey = (LPNMKEY)pNotifyStruct;
  753. if (!GetReportCtrl().GetFocusedRow())
  754. return;
  755. if (lpNMKey->nVKey == VK_RETURN)
  756. {
  757. CMessageRecord* pRecord = DYNAMIC_DOWNCAST(CMessageRecord, GetReportCtrl().GetFocusedRow()->GetRecord());
  758. if (pRecord)
  759. {
  760. if (pRecord->SetRead())
  761. {
  762. GetReportCtrl().Populate();
  763. }
  764. }
  765. }
  766. }
  767. // Handles double clicking ReportControl item.
  768. // If "Read" attribute is False, changes it to True
  769. void CReportSampleView::OnReportItemDblClick(NMHDR * pNotifyStruct, LRESULT * /*result*/)
  770. {
  771. XTP_NM_REPORTRECORDITEM* pItemNotify = (XTP_NM_REPORTRECORDITEM*) pNotifyStruct;
  772. if (pItemNotify->pRow)
  773. {
  774. TRACE(_T("Double Click on row %dn"),
  775. pItemNotify->pRow->GetIndex());
  776. CMessageRecord* pRecord = DYNAMIC_DOWNCAST(CMessageRecord, pItemNotify->pRow->GetRecord());
  777. if (pRecord)
  778. {
  779. if (pRecord->SetRead())
  780. {
  781. GetReportCtrl().Populate();
  782. }
  783. }
  784. }
  785. }
  786. // FieldChooser is used to add or remove fields (i.e. columns) using drag-and-drop. 
  787. // FieldChooser is an analog of a pool with column headers of none-used columns
  788. void CReportSampleView::OnShowFieldChooser()
  789. {
  790. CMainFrame* pMainFrm = (CMainFrame*)AfxGetMainWnd();
  791. if (pMainFrm)
  792. {
  793. BOOL bShow = !pMainFrm->m_wndFieldChooser.IsVisible();
  794. pMainFrm->ShowControlBar(&pMainFrm->m_wndFieldChooser, bShow, FALSE);
  795. }
  796. }
  797. // Tree View form demonstrates how hierarchy of ReportControl rows is shown in "tree" style
  798. void CReportSampleView::OnTreeViewDlg()
  799. {
  800. CTreeViewDlg dlgTreeView;
  801. dlgTreeView.DoModal();
  802. }
  803. // If enabled -- allows automatic formating. 
  804. void CReportSampleView::OnReportcontrolAutomaticformattingsample()
  805. {
  806. m_bAutomaticFormating = !m_bAutomaticFormating;
  807. GetReportCtrl().RedrawControl();
  808. }
  809. void CReportSampleView::OnUpdateReportcontrolAutomaticformattingsample(CCmdUI* pCmdUI)
  810. {
  811. pCmdUI->SetCheck(m_bAutomaticFormating);
  812. }
  813. // Adds a few sample Records to ReportControl. 
  814. void CReportSampleView::AddSampleRecords()
  815. {
  816. COleDateTime odtSent(COleDateTime::GetCurrentTime());
  817. COleDateTime odtCreated(COleDateTime::GetCurrentTime());
  818. COleDateTime odtReceived(COleDateTime::GetCurrentTime());
  819. CString strMessage;
  820. CString strSubject;
  821. CString strEmpty(_T(" "));
  822. CXTPReportControl& wndReport = GetReportCtrl();
  823. strMessage = _T("Simple Preview Text");
  824. strSubject = _T("Undeliverable Mail");
  825. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, _T("postmaster@mail.codejock.com"), strSubject, odtSent, 7, TRUE, 5,
  826. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  827. strEmpty, strEmpty, strEmpty,
  828. strEmpty, strEmpty,
  829. strMessage));   odtSent -= 0.8; odtReceived-= 0.8;
  830. strMessage = _T("Breaks words. Lines are automatically broken between words if a word would extend past the edge of the rectangle specified by the lpRect parameter. A carriage return-linefeed sequence also breaks the line.");
  831. strSubject = _T("Hi Mary Jane");
  832. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, _T("Peter Parker"), _T("RE: ") + strSubject, odtSent, 14, FALSE, 4.3,
  833. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  834. strEmpty, strEmpty, strEmpty,
  835. strEmpty, strEmpty,
  836. strMessage)); odtSent -= 0.8;odtReceived-= 0.8;
  837. strSubject = _T("");
  838. strMessage = _T("If you have several conditions to be tested together, and you know that one is more likely to pass or fail than the others, you can use a feature called 'short circuit evaluation' to speed the execution of your script. When JScript evaluates a logical expression, it only evaluates as many sub-expressions as required to get a result.");
  839. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, TRUE, FALSE, _T("James Howlett"), _T("RE:") + strSubject, odtSent, 24, FALSE, 56,
  840. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  841. strEmpty, strEmpty, strEmpty,
  842. strEmpty, strEmpty,
  843. strMessage)); odtSent -= 0.8;odtReceived-= 0.8;
  844. strMessage = _T("The MSDN Visual Studio 6.0 Library also provides information on the tools and technologies available with the Visual Studio suite.");
  845. strSubject = _T("error C2039: 'Serialize' : is not a member of 'CString'");
  846. wndReport.AddRecord(new CMessageRecord(msgImportanceLow, TRUE, TRUE, _T("Bruce Banner [bbanner@codetoolbox.com]"), _T("Re: ") + strSubject, odtSent, 14, TRUE, 12.2,
  847. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  848. strEmpty, strEmpty, strEmpty,
  849. strEmpty, strEmpty,
  850. strMessage)); odtSent -= 0.8;odtReceived-= 0.8;
  851. strMessage = _T("The Visual Studio Enterprise Edition includes all of the features available with the Visual Studio development tools. When installing the Visual Studio Enterprise Edition, you can elect to install enterprise features for use with these tools. In addition, Visual Basic and Visual C++ are available in separate enterprise editions.");
  852. strSubject = _T("Download GDI+ version 1.1");
  853. wndReport.AddRecord(new CMessageRecord(msgImportanceHigh, FALSE, FALSE, _T("QueryReply"), _T("Re: ") + strSubject, odtSent, 13, FALSE, 1.345,
  854. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  855. strEmpty, strEmpty, strEmpty,
  856. strEmpty, strEmpty,
  857. strMessage)); odtSent -= 0.8;odtReceived-= 0.8;
  858. strMessage = _T("The following table (email_example1@address.com) indicates whether a given feature is available with a given tool. If you (email_example2@address.com) acquired a separate enterprise edition of Visual Basic or Visual C++, you can use this table also to identify which of the Visual Studio enterprise features you received with your purchase. (Visual J++ and Visual InterDev are not offered as separate enterprise editions.) In addition, some of these features are available in professional editions with a subset of their enterprise edition functionality.");
  859. strSubject = _T("I don't understand:");
  860. wndReport.AddRecord(new CMessageRecord(msgImportanceLow, TRUE, FALSE, _T("James Howlett"), strSubject, odtSent, 24, FALSE, 5.4321,
  861. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  862. strEmpty, strEmpty, strEmpty,
  863. strEmpty, strEmpty,
  864. strMessage)); odtSent -= 0.8;odtReceived-= 0.8;
  865. strMessage = _T("Visual Studio contains many development tools for building your application.");
  866. strSubject = _T("Re: WIN32_FIND_DATA help ");
  867. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, TRUE, _T("Matthew Murdock"), strSubject, odtSent, 14, TRUE, 45,
  868. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  869. strEmpty, strEmpty, strEmpty,
  870. strEmpty, strEmpty,
  871. strMessage)); odtSent -= 8;odtReceived-= 0.8;
  872. strMessage = _T("To learn more about how each development tool implements data access, see the following documentation topics.");
  873. strSubject = _T("Re: Licensing ");
  874. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, TRUE, FALSE, _T("Louis Lane"), strSubject, odtSent, 13, TRUE, 0.5,
  875. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  876. strEmpty, strEmpty, strEmpty,
  877. strEmpty, strEmpty,
  878. strMessage)); odtSent -= 8;odtReceived-= 0.8;
  879. strMessage = _T("Introduces the Data Access Guide, which discusses data access and provides links to information on related tools and technologies.");
  880. strSubject = _T("Undeliverable Mail");
  881. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, _T("postmaster@mail.codejock.com"), strSubject, odtSent, 7, TRUE, 10,
  882. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  883. strEmpty, strEmpty, strEmpty,
  884. strEmpty, strEmpty,
  885. strMessage)); odtSent -= 80;odtReceived-= 0.8;
  886. // new records
  887. CString strFrom;
  888. strFrom = _T("CodeToolBox");
  889. strSubject = _T("[CodeToolBox] Newsletter (10 May 2004)");
  890. strMessage = _T("An in-between week here at CodeToolBox. VSLive was last week, TechEd is in a couple of weeks; Last month's article winners have been awarded and this month's voting is just starting; Last week was Winter and this week is forecast to be Summer. It makes a developer want to just kick back and crank some code right? Right?");
  891. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, strFrom, strSubject, odtSent, 7, TRUE, 10,
  892. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  893. strEmpty, strEmpty, strEmpty,
  894. strEmpty, strEmpty,
  895. strMessage));
  896. odtSent -= 7;
  897. strFrom = _T("Codejock Exchange");
  898. strSubject = _T("Good Answer! Capture message send from Net Send");
  899. strMessage = _T("Congratulations! Your answer has been accepted by SuperMan! You've earned 720 Expert Points and have been rewarded with a grade of A. These points will be added to your overall Expert Point total and to your Expert Point total in the Programming Topic Area.");
  900. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, strFrom, strSubject, odtSent, 8, FALSE, 720,
  901. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  902. strEmpty, strEmpty, strEmpty,
  903. strEmpty, strEmpty,
  904. strMessage));
  905. odtSent -= 7; odtReceived -= 14;
  906. strFrom = _T("CodeToolBox.com Team");
  907. strSubject = _T("CodeToolBox.com Sitewide update April 22nd, 2004");
  908. strMessage = _T("You have acquired this CodeToolBox.com update because you requested to be on the list. Honest! An explanation is at the bottom of this email, and also info on how to be extracted from the list.");
  909. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, strFrom, strSubject, odtSent, 46, FALSE, 28,
  910. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  911. strEmpty, strEmpty, strEmpty,
  912. strEmpty, strEmpty,
  913. strMessage));
  914. odtSent -= 7;
  915. strFrom = _T("Codejock Exchange");
  916. strSubject = _T("Comment Added: returning a <ma> from a dll");
  917. strMessage = _T("A comment has been added to this question by: somebody. Click the following URL to read the new comment:");
  918. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, strFrom, strSubject, odtSent, 5, FALSE, 30,
  919. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  920. strEmpty, strEmpty, strEmpty,
  921. strEmpty, strEmpty,
  922. strMessage));
  923. odtSent -= 7; odtReceived -= 14;
  924. strFrom = _T("Bruce Wayne");
  925. strSubject = _T("Comment Added: memory leak in OnEndEdit()?");
  926. strMessage = _T("A comment has been added to this question by: Robin. Click the following URL to read the new comment:");
  927. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, strFrom, strSubject, odtSent, 5, FALSE, 20,
  928. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  929. strEmpty, strEmpty, strEmpty,
  930. strEmpty, strEmpty,
  931. strMessage));
  932. odtSent -= 7;
  933. strFrom = _T("Codejock Exchange");
  934. strSubject = _T("Good Answer!: stl containers");
  935. strMessage = _T("Congratulations! Your proposed answer has been accepted by TheBeast! You've earned 300 Expert points and have been rewarded with a grade of B.");
  936. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, strFrom, strSubject, odtSent, 4, FALSE, 2,
  937. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  938. strEmpty, strEmpty, strEmpty,
  939. strEmpty, strEmpty,
  940. strMessage));
  941. odtSent -= 7; odtReceived -= 14;
  942. strFrom = _T("Codejock Exchange");
  943. strSubject = _T("Codejock Exchange:  Lost Member Name or Password");
  944. strMessage = _T("You are receiving this email because you reported that you could not remember your Codejock Exchange Member Name or password.");
  945. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, strFrom, strSubject, odtSent, 7, FALSE, 1,
  946. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  947. strEmpty, strEmpty, strEmpty,
  948. strEmpty, strEmpty,
  949. strMessage));
  950. odtSent -= 7;
  951. strFrom = _T("CodejockDirect");
  952. strSubject = _T("New volume/issues available on CodejockDirect");
  953. strMessage = _T("New volume/issues are now available for the following on CodejockDirect! * Mathematical and Computer Modelling");
  954. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, strFrom, strSubject, odtSent, 9, FALSE, 12,
  955. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  956. strEmpty, strEmpty, strEmpty,
  957. strEmpty, strEmpty,
  958. strMessage));
  959. odtSent -= 7;
  960. strFrom = _T("Kyle Rayner");
  961. strSubject = _T("info");
  962. strMessage = _T("OR-Library is a collection of test data sets for a variety of problem areas. These test data sets can be accessed via emailing to CodeToolBox.com a message containing the name of the required file, or via ftp/WWW using the addresses given at the bottom of this file.");
  963. wndReport.AddRecord(new CMessageRecord(msgImportanceNormal, FALSE, FALSE, strFrom, strSubject, odtSent, 67, FALSE, 10,
  964. odtReceived, odtCreated, strSubject, strEmpty, strMessage,
  965. strEmpty, strEmpty, strEmpty,
  966. strEmpty, strEmpty,
  967. strMessage));
  968. odtSent -= 7; odtReceived -= 14;
  969. }
  970. // Set horizontal grid lines style.
  971. // Following styles are available:
  972. //  No Grid lines;
  973. //  Small dots
  974. //  Large Dots
  975. //  Dashes
  976. //  Solid
  977. void CReportSampleView::OnGridHorizontal(UINT nID)
  978. {
  979. GetReportCtrl().SetGridStyle(FALSE, (XTPReportGridStyle)(nID - ID_GRID_HORIZONTAL_NOGRIDLINES));
  980. }
  981. void CReportSampleView::OnUpdateGridHorizontal(CCmdUI* pCmdUI)
  982. {
  983. pCmdUI->SetCheck(((int)pCmdUI->m_nID - ID_GRID_HORIZONTAL_NOGRIDLINES) == GetReportCtrl().GetGridStyle(FALSE));
  984. }
  985. // Set vertical grid lines style.
  986. // Following styles are available:
  987. //  No Grid lines;
  988. //  Small dots
  989. //  Large Dots
  990. //  Dashes
  991. //  Solid
  992. void CReportSampleView::OnGridVertical(UINT nID)
  993. {
  994. GetReportCtrl().SetGridStyle(TRUE, (XTPReportGridStyle)(nID - ID_GRID_VERTICAL_NOGRIDLINES));
  995. }
  996. void CReportSampleView::OnUpdateGridVertical(CCmdUI* pCmdUI)
  997. {
  998. pCmdUI->SetCheck(((int)pCmdUI->m_nID - ID_GRID_VERTICAL_NOGRIDLINES) == GetReportCtrl().GetGridStyle(TRUE));
  999. }
  1000. // Allow or forbid column resize  
  1001. void CReportSampleView::OnOptionsAllowcolumnresize()
  1002. {
  1003. GetReportCtrl().GetReportHeader()->AllowColumnResize(!GetReportCtrl().GetReportHeader()->IsAllowColumnResize());
  1004. }
  1005. void CReportSampleView::OnUpdateOptionsAllowcolumnresize(CCmdUI* pCmdUI)
  1006. {
  1007. pCmdUI->SetCheck(GetReportCtrl().GetReportHeader()->IsAllowColumnResize());
  1008. }
  1009. // Allow or forbid columns removal 
  1010. void CReportSampleView::OnOptionsAllowcolumnsremove()
  1011. {
  1012. GetReportCtrl().GetReportHeader()->AllowColumnRemove(!GetReportCtrl().GetReportHeader()->IsAllowColumnRemove());
  1013. }
  1014. void CReportSampleView::OnUpdateOptionsAllowcolumnsremove(CCmdUI* pCmdUI)
  1015. {
  1016. pCmdUI->SetCheck(GetReportCtrl().GetReportHeader()->IsAllowColumnRemove());
  1017. }
  1018. // Allow or forbid columns reordering
  1019. void CReportSampleView::OnReportheaderAllowcolumnreorder() 
  1020. {
  1021. GetReportCtrl().GetReportHeader()->AllowColumnReorder(!GetReportCtrl().GetReportHeader()->IsAllowColumnReorder());
  1022. }
  1023. void CReportSampleView::OnUpdateReportheaderAllowcolumnreorder(CCmdUI* pCmdUI) 
  1024. {
  1025. pCmdUI->SetCheck(GetReportCtrl().GetReportHeader()->IsAllowColumnReorder());
  1026. }
  1027. // Allow or forbid simultaneous selection of several records
  1028. void CReportSampleView::OnOptionsMultipleselection()
  1029. {
  1030. GetReportCtrl().SetMultipleSelection(!GetReportCtrl().IsMultipleSelection());
  1031. }
  1032. void CReportSampleView::OnUpdateOptionsMultipleselection(CCmdUI* pCmdUI)
  1033. {
  1034. pCmdUI->SetCheck(GetReportCtrl().IsMultipleSelection());
  1035. }
  1036. // Allow or forbid records grouping
  1037. void CReportSampleView::OnOptionsShowitemsingroups()
  1038. {
  1039. GetReportCtrl().GetReportHeader()->ShowItemsInGroups(!GetReportCtrl().GetReportHeader()->IsShowItemsInGroups());
  1040. if (!GetReportCtrl().GetReportHeader()->IsShowItemsInGroups())
  1041. {
  1042. GetReportCtrl().GetColumns()->GetGroupsOrder()->Clear();
  1043. GetReportCtrl().Populate();
  1044. }
  1045. }
  1046. void CReportSampleView::OnUpdateOptionsShowitemsingroups(CCmdUI* pCmdUI)
  1047. {
  1048. pCmdUI->SetCheck(GetReportCtrl().GetReportHeader()->IsShowItemsInGroups());
  1049. }
  1050. // Allow or forbid automatic columns resizing
  1051. void CReportSampleView::OnOptionsAutomaticcolumnsizing()
  1052. {
  1053. GetReportCtrl().GetReportHeader()->SetAutoColumnSizing(!GetReportCtrl().GetReportHeader()->IsAutoColumnSizing());
  1054. }
  1055. void CReportSampleView::OnUpdateOptionsAutomaticcolumnsizing(CCmdUI* pCmdUI)
  1056. {
  1057. pCmdUI->SetCheck(GetReportCtrl().GetReportHeader()->IsAutoColumnSizing());
  1058. }
  1059. void CReportSampleView::OnOptionsFullColumnScrolling()
  1060. {
  1061. GetReportCtrl().SetFullColumnScrolling(!GetReportCtrl().IsFullColumnScrolling());
  1062. }
  1063. void CReportSampleView::OnUpdateOptionsFullColumnScrolling(CCmdUI* pCmdUI)
  1064. {
  1065. pCmdUI->SetCheck(GetReportCtrl().IsFullColumnScrolling());
  1066. }
  1067. void CReportSampleView::OnSetFocus(CWnd* pOldWnd)
  1068. {
  1069. CView::OnSetFocus(pOldWnd);
  1070. GetReportCtrl().SetFocus();
  1071. }
  1072. void CReportSampleView::OnTestTasklist()
  1073. {
  1074. if (m_pTaskFrame)
  1075. {
  1076. m_pTaskFrame->ActivateFrame();
  1077. return;
  1078. }
  1079. CCreateContext contextT;
  1080. // if no context specified, generate one from the
  1081. // currently selected client if possible.
  1082. contextT.m_pLastView       = NULL;
  1083. contextT.m_pCurrentFrame   = NULL;
  1084. contextT.m_pNewDocTemplate = NULL;
  1085. contextT.m_pCurrentDoc     = NULL;
  1086. contextT.m_pNewViewClass   = RUNTIME_CLASS(CTaskListView);
  1087. m_pTaskFrame = new CTaskListFrame(this);
  1088. DWORD dwStyle = WS_OVERLAPPEDWINDOW|FWS_ADDTOTITLE;
  1089. m_pTaskFrame->LoadFrame(IDR_TASKLIST, dwStyle, 0, &contextT);
  1090. m_pTaskFrame->InitialUpdateFrame(NULL, FALSE);
  1091. m_pTaskFrame->ShowWindow(SW_SHOW);
  1092. }
  1093. void CReportSampleView::OnTestProperties()
  1094. {
  1095. if (m_pPropertiesFrame)
  1096. {
  1097. m_pPropertiesFrame->ActivateFrame();
  1098. return;
  1099. }
  1100. CCreateContext contextT;
  1101. // if no context specified, generate one from the
  1102. // currently selected client if possible.
  1103. contextT.m_pLastView       = NULL;
  1104. contextT.m_pCurrentFrame   = NULL;
  1105. contextT.m_pNewDocTemplate = NULL;
  1106. contextT.m_pCurrentDoc     = NULL;
  1107. contextT.m_pNewViewClass   = RUNTIME_CLASS(CPropertiesView);
  1108. m_pPropertiesFrame = new CPropertiesFrame(this);
  1109. DWORD dwStyle = WS_OVERLAPPEDWINDOW|MFS_SYNCACTIVE;
  1110. if (!m_pPropertiesFrame->Create(0, _T("Properties"), dwStyle, CRect(0, 0, 400, 350),
  1111. this, 0, 0L, &contextT))
  1112. {
  1113. return ;   // will self destruct on failure normally
  1114. }
  1115. m_pPropertiesFrame->InitialUpdateFrame(NULL, FALSE);
  1116. m_pPropertiesFrame->CenterWindow(this);
  1117. m_pPropertiesFrame->ShowWindow(SW_SHOW);
  1118. }
  1119. void CReportSampleView::OnTestPerfomance()
  1120. {
  1121. CPerfomanceTestDlg dlg;
  1122. dlg.DoModal();
  1123. }
  1124. void CReportSampleView::OnReportcontrolMultilinesample()
  1125. {
  1126. m_bMultilineSample = !m_bMultilineSample;
  1127. // Custom implementation (from old version).
  1128. // For new versions of the ReportControl this feature is built-in.
  1129. //-----------------------------------------------------------------------------
  1130. // if (m_bMultilineSample)
  1131. // {
  1132. // GetReportCtrl().SetPaintManager(new CReportMultilinePaintManager());
  1133. // GetReportCtrl().EnableToolTips(FALSE);
  1134. // }
  1135. // else
  1136. // {
  1137. // GetReportCtrl().SetPaintManager(new CXTPReportPaintManager());
  1138. // GetReportCtrl().EnableToolTips(TRUE);
  1139. // }
  1140. //-----------------------------------------------------------------------------
  1141. int nCount = GetReportCtrl().GetColumns()->GetCount();
  1142. for( int i = 0; i < nCount; i++) 
  1143. {
  1144. CXTPReportColumn* pColumn = GetReportCtrl().GetColumns()->GetAt(i);
  1145. if (pColumn) 
  1146. {
  1147. int nAlign = pColumn->GetAlignment();
  1148. nAlign = m_bMultilineSample ? (nAlign | DT_WORDBREAK) : (nAlign & (~DT_WORDBREAK));
  1149. pColumn->SetAlignment(nAlign);
  1150. }
  1151. }
  1152. GetReportCtrl().GetPaintManager()->SetFixedRowHeight(!m_bMultilineSample);
  1153. GetReportCtrl().GetPaintManager()->m_bUseColumnTextAlignment = TRUE;
  1154. //
  1155. GetReportCtrl().AdjustScrollBars();
  1156. }
  1157. void CReportSampleView::OnUpdateReportcontrolMultilinesample(CCmdUI* pCmdUI)
  1158. {
  1159. pCmdUI->SetCheck(m_bMultilineSample);
  1160. }
  1161. // Set column header draw style.
  1162. // Following styles are available:
  1163. //   Shaded
  1164. //   Flat
  1165. //   Explorer
  1166. //   Office2003
  1167. //   Office2007
  1168. void CReportSampleView::OnColumnStyle(UINT nID) 
  1169. {
  1170. GetReportCtrl().GetPaintManager()->SetColumnStyle(XTPReportColumnStyle(nID - ID_COLUMNSTYLE_SHADED));
  1171. GetReportCtrl().RedrawControl();
  1172. }
  1173. void CReportSampleView::OnUpdateColumnStyle(CCmdUI* pCmdUI) 
  1174. {
  1175. pCmdUI->SetCheck(GetReportCtrl().GetPaintManager()->GetColumnStyle() == XTPReportColumnStyle(pCmdUI->m_nID - ID_COLUMNSTYLE_SHADED)? TRUE: FALSE);
  1176. }
  1177. void CReportSampleView::OnReportBeforePasteFromText(NMHDR * pNotifyStruct, LRESULT *result)
  1178. {
  1179. ASSERT(pNotifyStruct);
  1180. XTP_NM_REPORT_BEFORE_COPYPASTE* pnmCopyPaste = (XTP_NM_REPORT_BEFORE_COPYPASTE*)pNotifyStruct; 
  1181. if(!pnmCopyPaste || !pnmCopyPaste->ppRecord || !pnmCopyPaste->parStrings) {
  1182. ASSERT(FALSE);
  1183. return;
  1184. }
  1185. CMessageRecord* pRecord = new CMessageRecord();
  1186. if(!pRecord) {
  1187. return;
  1188. }
  1189. *pnmCopyPaste->ppRecord = pRecord;
  1190. CXTPReportColumns* pColumns = GetReportCtrl().GetColumns();
  1191. ASSERT(pColumns);
  1192. if(!pColumns) {
  1193. return;
  1194. }
  1195. int nDataCount = (int)pnmCopyPaste->parStrings->GetSize();
  1196. const int nColumnCount = pColumns->GetVisibleColumnsCount();
  1197. for (int nCol = 0; nCol < nColumnCount; nCol++)
  1198. {
  1199. CXTPReportColumn* pColumn = pColumns->GetVisibleAt(nCol);
  1200. CXTPReportRecordItem* pItem = pRecord->GetItem(pColumn);
  1201. ASSERT(pItem);
  1202. if (NULL == pItem)
  1203. continue;
  1204. if(nCol < nDataCount) 
  1205. {
  1206. CString strItem = pnmCopyPaste->parStrings->GetAt(nCol);
  1207. pItem->SetCaption(strItem);
  1208. }
  1209. }
  1210. *result = 1;
  1211. }
  1212. void CReportSampleView::OnOptionsFreezecolumns0() 
  1213. {
  1214. GetReportCtrl().SetFreezeColumnsCount(0);
  1215. GetReportCtrl().RedrawControl();
  1216. }
  1217. void CReportSampleView::OnUpdateOptionsFreezecolumns0(CCmdUI* pCmdUI) 
  1218. {
  1219. pCmdUI->SetCheck(GetReportCtrl().GetFreezeColumnsCount() == 0 ? 1 : 0);
  1220. }
  1221. void CReportSampleView::OnOptionsFreezecolumns1() 
  1222. {
  1223. GetReportCtrl().SetFreezeColumnsCount(1);
  1224. GetReportCtrl().RedrawControl();
  1225. }
  1226. void CReportSampleView::OnUpdateOptionsFreezecolumns1(CCmdUI* pCmdUI) 
  1227. {
  1228. pCmdUI->SetCheck(GetReportCtrl().GetFreezeColumnsCount() == 1 ? 1 : 0);
  1229. }
  1230. void CReportSampleView::OnOptionsFreezecolumns2() 
  1231. {
  1232. GetReportCtrl().SetFreezeColumnsCount(2);
  1233. GetReportCtrl().RedrawControl();
  1234. }
  1235. void CReportSampleView::OnUpdateOptionsFreezecolumns2(CCmdUI* pCmdUI) 
  1236. {
  1237. pCmdUI->SetCheck(GetReportCtrl().GetFreezeColumnsCount() == 2 ? 1 : 0);
  1238. }
  1239. void CReportSampleView::OnOptionsFreezecolumns3() 
  1240. {
  1241. GetReportCtrl().SetFreezeColumnsCount(3);
  1242. GetReportCtrl().RedrawControl();
  1243. }
  1244. void CReportSampleView::OnUpdateOptionsFreezecolumns3(CCmdUI* pCmdUI) 
  1245. {
  1246. pCmdUI->SetCheck(GetReportCtrl().GetFreezeColumnsCount() == 3 ? 1 : 0);
  1247. }
  1248. void CReportSampleView::OnReportcontrolRighttoleft() 
  1249. {
  1250. GetReportCtrl().SetLayoutRTL(GetReportCtrl().GetExStyle() & WS_EX_LAYOUTRTL ? FALSE : TRUE);
  1251. }
  1252. void CReportSampleView::OnUpdateReportcontrolRighttoleft(CCmdUI* pCmdUI) 
  1253. {
  1254. if (!XTPSystemVersion()->IsLayoutRTLSupported())
  1255. {
  1256. pCmdUI->Enable(FALSE);
  1257. }
  1258. else
  1259. {
  1260. pCmdUI->SetCheck(GetReportCtrl().GetExStyle() & WS_EX_LAYOUTRTL ? TRUE : FALSE);
  1261. }
  1262. }
  1263. void CReportSampleView::OnOptionsFreezecolumnsDivider1() 
  1264. {
  1265. int nStyle = GetReportCtrl().GetPaintManager()->GetFreezeColsDividerStyle();
  1266. nStyle &= ~(xtpReportFreezeColsDividerBold | xtpReportFreezeColsDividerThin);
  1267. nStyle |= xtpReportFreezeColsDividerThin;
  1268. GetReportCtrl().GetPaintManager()->SetFreezeColsDividerStyle(nStyle);
  1269. GetReportCtrl().RedrawControl();
  1270. }
  1271. void CReportSampleView::OnOptionsFreezecolumnsDivider2() 
  1272. {
  1273. int nStyle = GetReportCtrl().GetPaintManager()->GetFreezeColsDividerStyle();
  1274. nStyle &= ~(xtpReportFreezeColsDividerBold | xtpReportFreezeColsDividerThin);
  1275. nStyle |= xtpReportFreezeColsDividerBold;
  1276. GetReportCtrl().GetPaintManager()->SetFreezeColsDividerStyle(nStyle);
  1277. GetReportCtrl().RedrawControl();
  1278. }
  1279. void CReportSampleView::OnUpdateOptionsFreezecolumnsDivider1(CCmdUI* pCmdUI) 
  1280. {
  1281. int nStyle = GetReportCtrl().GetPaintManager()->GetFreezeColsDividerStyle();
  1282. pCmdUI->SetCheck((nStyle & xtpReportFreezeColsDividerThin) != 0);
  1283. }
  1284. void CReportSampleView::OnUpdateOptionsFreezecolumnsDivider2(CCmdUI* pCmdUI) 
  1285. {
  1286. int nStyle = GetReportCtrl().GetPaintManager()->GetFreezeColsDividerStyle();
  1287. pCmdUI->SetCheck((nStyle & xtpReportFreezeColsDividerBold) != 0);
  1288. }
  1289. void CReportSampleView::OnOptionsFreezecolumnsDividerHeader() 
  1290. {
  1291. int nStyle = GetReportCtrl().GetPaintManager()->GetFreezeColsDividerStyle();
  1292. nStyle ^= xtpReportFreezeColsDividerHeader;
  1293. GetReportCtrl().GetPaintManager()->SetFreezeColsDividerStyle(nStyle);
  1294. GetReportCtrl().RedrawControl();
  1295. }
  1296. void CReportSampleView::OnUpdateOptionsFreezecolumnsDividerHeader(CCmdUI* pCmdUI) 
  1297. {
  1298. int nStyle = GetReportCtrl().GetPaintManager()->GetFreezeColsDividerStyle();
  1299. pCmdUI->SetCheck((nStyle & xtpReportFreezeColsDividerHeader) != 0);
  1300. }
  1301. void CReportSampleView::OnOptionsFreezecolumnsDividerNone() 
  1302. {
  1303. int nStyle = GetReportCtrl().GetPaintManager()->GetFreezeColsDividerStyle();
  1304. nStyle = (nStyle & (xtpReportFreezeColsDividerHeader));
  1305. GetReportCtrl().GetPaintManager()->SetFreezeColsDividerStyle(nStyle);
  1306. GetReportCtrl().RedrawControl();
  1307. }
  1308. void CReportSampleView::OnUpdateOptionsFreezecolumnsDividerNone(CCmdUI* pCmdUI) 
  1309. {
  1310. int nStyle = GetReportCtrl().GetPaintManager()->GetFreezeColsDividerStyle();
  1311. pCmdUI->SetCheck((nStyle & ~xtpReportFreezeColsDividerHeader) == 0);
  1312. }
  1313. void CReportSampleView::OnOptionsFreezecolumnsDividerShade() 
  1314. {
  1315. int nStyle = GetReportCtrl().GetPaintManager()->GetFreezeColsDividerStyle();
  1316. nStyle ^= xtpReportFreezeColsDividerShade;
  1317. GetReportCtrl().GetPaintManager()->SetFreezeColsDividerStyle(nStyle);
  1318. GetReportCtrl().RedrawControl();
  1319. }
  1320. void CReportSampleView::OnUpdateOptionsFreezecolumnsDividerShade(CCmdUI* pCmdUI) 
  1321. {
  1322. int nStyle = GetReportCtrl().GetPaintManager()->GetFreezeColsDividerStyle();
  1323. pCmdUI->SetCheck((nStyle & xtpReportFreezeColsDividerShade) != 0);
  1324. }
  1325. void CReportSampleView::OnTestHeaderFooter()
  1326. {
  1327. if (m_pHeaderFooterFrame)
  1328. {
  1329. m_pHeaderFooterFrame->ActivateFrame();
  1330. return;
  1331. }
  1332. CCreateContext contextT;
  1333. // if no context specified, generate one from the
  1334. // currently selected client if possible.
  1335. contextT.m_pLastView       = NULL;
  1336. contextT.m_pCurrentFrame   = NULL;
  1337. contextT.m_pNewDocTemplate = NULL;
  1338. contextT.m_pCurrentDoc     = NULL;
  1339. contextT.m_pNewViewClass   = RUNTIME_CLASS(CHeaderFooterView);
  1340. m_pHeaderFooterFrame = new CHeaderFooterFrame(this);
  1341. DWORD dwStyle = WS_OVERLAPPEDWINDOW|FWS_ADDTOTITLE;
  1342. m_pHeaderFooterFrame->LoadFrame(IDR_HEADERFOOTER, dwStyle, 0, &contextT);
  1343. m_pHeaderFooterFrame->InitialUpdateFrame(NULL, FALSE);
  1344. m_pHeaderFooterFrame->ShowWindow(SW_SHOW);
  1345. }