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

对话框与窗口

开发平台:

Visual C++

  1. // CalendarDemo.cpp : Defines the class behaviors for the application.
  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 "CalendarDemo.h"
  22. #include "MainFrm.h"
  23. #include "CalendarDemoDoc.h"
  24. #include "CalendarDemoView.h"
  25. #include "DataProvidersOptions.h"
  26. #include "CalendarResourcesDlg.h"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. BOOL IsFileExist(LPCTSTR pcszFile)
  33. {
  34. return FILEEXISTS_S(pcszFile);
  35. }
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CCalendarDemoApp
  38. BEGIN_MESSAGE_MAP(CCalendarDemoApp, CWinApp)
  39. //{{AFX_MSG_MAP(CCalendarDemoApp)
  40. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  41. //}}AFX_MSG_MAP
  42. // Standard file based document commands
  43. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  44. ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  45. // Standard print setup command
  46. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  47. // Multiple schedules menu items
  48. ON_COMMAND(ID_FILE_MULTISCHEDULES_CFG, OnMultiSchedulesCfg)
  49. ON_COMMAND(ID_FILE_LOAD_SAMPLE_MULTISCHEDULES_SIMPLE, OnMultiSchedulesSample)
  50. ON_COMMAND(ID_FILE_LOAD_SAMPLE_MULTISCHEDULES_EXTENDED, OnMultiSchedulesSampleExt)
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CCalendarDemoApp construction
  54. CCalendarDemoApp::CCalendarDemoApp()
  55. {
  56. m_bOnOpenFile_AppStarting = TRUE;
  57. m_bOnOpenFile_CreateNewIfNotExist = FALSE;
  58. m_pCalRCman = NULL;
  59. }
  60. /////////////////////////////////////////////////////////////////////////////
  61. // The one and only CCalendarDemoApp object
  62. CCalendarDemoApp theApp;
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CCalendarDemoApp initialization
  65. BOOL CCalendarDemoApp::InitInstance()
  66. {
  67. VERIFY( AfxOleInit() );
  68. AfxEnableControlContainer();
  69. CXTPWinDwmWrapper().SetProcessDPIAware();
  70. // Standard initialization
  71. // If you are not using these features and wish to reduce the size
  72. //  of your final executable, you should remove from the following
  73. //  the specific initialization routines you do not need.
  74. #if _MSC_VER <= 1200 //MFC 6.0 or earlier
  75. #ifdef _AFXDLL
  76. Enable3dControls(); // Call this when using MFC in a shared DLL
  77. #else
  78. Enable3dControlsStatic(); // Call this when linking to MFC statically
  79. #endif
  80. #endif
  81. // Change the registry key under which our settings are stored.
  82. // TODO: You should modify this string to be something appropriate
  83. // such as the name of your company or organization.
  84. SetRegistryKey(_T("Codejock Software Sample Applications"));
  85. LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  86. // Register the application's document templates.  Document templates
  87. //  serve as the connection between documents, frame windows and views.
  88. CSingleDocTemplate* pDocTemplate;
  89. pDocTemplate = new CSingleDocTemplate(
  90. IDR_MAINFRAME,
  91. RUNTIME_CLASS(CCalendarDemoDoc),
  92. RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  93. RUNTIME_CLASS(CCalendarDemoView));
  94. AddDocTemplate(pDocTemplate);
  95.     
  96. /* BOOL bIsShift = (GetKeyState(VK_SHIFT) & 0x8000) != 0;
  97. CString strUseDP = GetProfileString(cstrDP_Opt_section, cstrUseDP_opt);
  98. BOOL bPostShowOpenNewDialog = strUseDP.IsEmpty() || bIsShift;
  99. BOOL nNoFile = FALSE;
  100. // Parse command line for standard shell commands, DDE, file open
  101. CCommandLineInfo cmdInfo;
  102. if(strUseDP.CompareNoCase(cstrUseDP_Mem_optval) == 0) {
  103. cmdInfo.m_strFileName = GetProfileString(cstrDP_Opt_section, cstrUseDP_Mem_File_opt);
  104. else if(strUseDP.CompareNoCase(cstrUseDP_DB_optval) == 0) {
  105. cmdInfo.m_strFileName = GetProfileString(cstrDP_Opt_section, cstrUseDP_DB_File_opt);
  106. else if(strUseDP.CompareNoCase(cstrUseDP_MAPI_optval) == 0) {
  107. cmdInfo.m_strFileName = _T("mapi:");
  108. nNoFile = TRUE;
  109. else {
  110. ASSERT(strUseDP.IsEmpty());
  111. }
  112. BOOL bFileExist = !cmdInfo.m_strFileName.IsEmpty() && 
  113. IsFileExist(cmdInfo.m_strFileName);
  114. if(!bPostShowOpenNewDialog && bFileExist) 
  115. {
  116. cmdInfo.m_nShellCommand = CCommandLineInfo::FileOpen;
  117. }
  118. else {
  119. cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew;
  120. cmdInfo.m_strFileName = _T("");
  121. m_bOnOpenFile_CreateNewIfNotExist = TRUE;
  122. bPostShowOpenNewDialog = TRUE;
  123. CCalendarDemoDoc::ms_bFileNew_CreateEmptyDocument = TRUE;
  124. }
  125. */
  126. // Parse command line for standard shell commands, DDE, file open
  127. CCommandLineInfo cmdInfo;
  128. cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew;
  129. cmdInfo.m_strFileName = _T("");
  130. m_bOnOpenFile_AppStarting = TRUE;
  131. BOOL bPostShowOpenNewDialog = TRUE;
  132. CCalendarDemoDoc::ms_bFileNew_CreateEmptyDocument = TRUE;
  133. ParseCommandLine(cmdInfo);
  134. // Dispatch commands specified on the command line
  135. if (!ProcessShellCommand(cmdInfo))
  136. return FALSE;
  137. // The one and only window has been initialized, so show and update it.
  138. if(m_pMainWnd) 
  139. {
  140. m_pMainWnd->SetForegroundWindow();
  141. if(bPostShowOpenNewDialog) 
  142. {
  143. m_pMainWnd->PostMessage(WM_COMMAND, ID_FILE_OPEN);
  144. }
  145. m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
  146. m_pMainWnd->UpdateWindow();
  147. }
  148. return TRUE;
  149. }
  150. int CCalendarDemoApp::ExitInstance()
  151. {
  152. CMDTARGET_RELEASE(m_pCalRCman);
  153. return CWinApp::ExitInstance();
  154. }
  155. // Choose a new Calendar Data Provider and set its options.
  156. void CCalendarDemoApp::OnFileOpen()
  157. {
  158. BOOL bAppStarting = m_bOnOpenFile_AppStarting;
  159. if (m_bOnOpenFile_AppStarting)
  160. {
  161. m_bOnOpenFile_AppStarting = FALSE;
  162. int nDlgRes = AfxMessageBox(_T("Would you like to populate the calendar with sample data? nSelect No to open an existing data provider."), MB_YESNOCANCEL);
  163. if (nDlgRes == IDYES)
  164. {
  165. CCalendarDemoDoc::ms_bFileNew_CreateEmptyDocument = TRUE;
  166. CCalendarDemoDoc::ms_bEmptyDocument_AddSampleData = TRUE;
  167. OnFileNew();
  168. return;
  169. }
  170. else if (nDlgRes == IDCANCEL)
  171. {
  172. CCalendarDemoDoc::ms_bFileNew_CreateEmptyDocument = TRUE;
  173. OnFileNew();
  174. return;
  175. }
  176. else 
  177. {
  178. CCalendarDemoDoc::ms_bFileNew_CreateEmptyDocument = FALSE;
  179. }
  180. }
  181. else 
  182. {
  183. // Open Data Providers choice dialog
  184. CDataProvidersOptions optDlg;
  185. optDlg.m_strTitle = _T("Open file");
  186. optDlg.m_bOpenMode = TRUE;
  187. int nDlgRes = (int)optDlg.DoModal();
  188. if(nDlgRes != IDOK) {
  189. return;
  190. }
  191. }
  192. CString strUseDP = GetProfileString(cstrDP_Opt_section, cstrUseDP_opt);
  193. CString strFileName;
  194. if(strUseDP.CompareNoCase(cstrUseDP_Mem_optval) == 0) {
  195. strFileName = GetProfileString(cstrDP_Opt_section, cstrUseDP_Mem_File_opt);
  196. else if(strUseDP.CompareNoCase(cstrUseDP_DB_optval) == 0) {
  197. strFileName = GetProfileString(cstrDP_Opt_section, cstrUseDP_DB_File_opt);
  198. else if(strUseDP.CompareNoCase(cstrUseDP_MAPI_optval) == 0) 
  199. {
  200. CCalendarDemoDoc::ms_bFileNew_ShowDialog = bAppStarting;
  201. OnFileNew();
  202. return;
  203. }
  204. else if (strUseDP.IsEmpty())
  205. {
  206. CCalendarDemoDoc::ms_bFileNew_ShowDialog = TRUE;
  207. OnFileNew();
  208. return;
  209. }
  210. else
  211. {
  212. ASSERT(FALSE);
  213. return;
  214. }
  215. // If you're trying to open an existing file into data provider
  216. if(IsFileExist(strFileName)) 
  217. {
  218. OpenDocumentFile(strFileName);
  219. }
  220. else 
  221. {
  222. // Otherwise, you're creating a new data file
  223. int nRes = AfxMessageBox(_T("The events data file is not exist.nWould You like to create it?"), MB_YESNO);
  224. if(nRes == IDYES) {
  225. CCalendarDemoDoc::ms_bFileNew_ShowDialog = FALSE;
  226. OnFileNew();
  227. else {
  228. OnFileOpen();
  229. }
  230. }
  231. }
  232. CCalendarDemoView* CCalendarDemoApp::GetCalendarDemoView()
  233. {
  234. // for single doc template only
  235. POSITION posDOCTempl = GetFirstDocTemplatePosition();
  236. CDocTemplate* pDocTemplate = GetNextDocTemplate(posDOCTempl);
  237. POSITION posDOC = pDocTemplate ? pDocTemplate->GetFirstDocPosition() : NULL;
  238. CDocument* pDocument = pDocTemplate ? pDocTemplate->GetNextDoc(posDOC) : NULL;
  239. POSITION posView = pDocument ? pDocument->GetFirstViewPosition() : NULL;
  240. CView* pView = pDocument ? pDocument->GetNextView(posView) : NULL;
  241.     
  242. CCalendarDemoView* pDemoView = pView ? DYNAMIC_DOWNCAST(CCalendarDemoView, pView) : NULL;
  243. return pDemoView;
  244. }
  245. // App command to run the dialog
  246. void CCalendarDemoApp::OnAppAbout()
  247. {
  248. if((GetKeyState(VK_SHIFT)&0x8000) && (GetKeyState(VK_CONTROL)&0x8000)) 
  249. {
  250. CCalendarDemoView* pDemoView = GetCalendarDemoView();
  251. ASSERT(pDemoView);
  252. if(pDemoView) 
  253. {
  254. CXTPCalendarData* pCData = pDemoView->GetCalendarCtrl().GetDataProvider();
  255. CCalendarInternalOptions optInternal(pCData);
  256. optInternal.DoModal();
  257. return;
  258. }
  259. }
  260. CAboutDlg aboutDlg;
  261. aboutDlg.DoModal();
  262. }
  263. void CCalendarDemoApp::OnMultiSchedulesCfg()
  264. {
  265. // Get Calendar pointer
  266. CCalendarDemoView* pDemoView = GetCalendarDemoView();
  267. ASSERT(pDemoView);
  268. if(!pDemoView)
  269. return;
  270. CXTPCalendarControl* pCalendar = &pDemoView->GetCalendarCtrl();
  271. // Prepare Resource Manager
  272. CString strCfgFile = GetModulePath() +_T("CalendarMultiResourcesConfigCustom.xml");
  273. if (!m_pCalRCman)
  274. {
  275. m_pCalRCman = new CXTPCalendarResourcesManager();
  276. if (!m_pCalRCman) {
  277. return;
  278. }
  279. m_pCalRCman->LoadCfg(strCfgFile);
  280. }
  281. // Show Resource Manager dialog
  282. CCalendarResourcesDlg dlgCalRC(m_pCalRCman);
  283. int nDlgRes = (int)dlgCalRC.DoModal();
  284. if (nDlgRes != IDOK)
  285. return;
  286. // Save and apply changed resources configuration
  287. m_pCalRCman->SaveCfg(strCfgFile);
  288. m_pCalRCman->ApplyToCalendar(pCalendar);
  289. pCalendar->Populate();
  290. pCalendar->RedrawControl();
  291. // Update Sample caption
  292. CString strTitle = _T("Multiple Schedules configuration: ") + strCfgFile;
  293. pDemoView->GetDocument()->CDocument::SetTitle(strTitle);
  294. }
  295. CString CCalendarDemoApp::GetModulePath()
  296. {
  297. TCHAR szCurPath[_MAX_PATH + 2];
  298. ::GetModuleFileName(AfxGetInstanceHandle(), szCurPath, _MAX_PATH);
  299. CString strCurPath(szCurPath);
  300. strCurPath = strCurPath.Left(strCurPath.ReverseFind('\')+1);
  301. return strCurPath;
  302. }
  303. // Create Multiple Schedules sample configuration without 
  304. // using Calendar Resources Manager.
  305. void CCalendarDemoApp::OnMultiSchedulesSample()
  306. {
  307. // Get Calendar pointer
  308. CCalendarDemoView* pDemoView = GetCalendarDemoView();
  309. if(!pDemoView)
  310. return;
  311. CXTPCalendarControl* pCalendar = &pDemoView->GetCalendarCtrl();
  312. // Setup sample configuration
  313. // ** data provider
  314. CString strConnectionString = _T("Provider=XML;Data Source=") + 
  315. GetModulePath() + _T("CalendarMultipleSchedulesSample.xtp_cal");
  316. CXTPCalendarData* pData = CXTPCalendarControl::CreateDataProvider(strConnectionString);
  317. if (!pData)
  318. return;
  319. if (!pData->Open()) 
  320. {
  321. VERIFY( pData->Create() );
  322. }
  323. // ** schedules
  324. CXTPCalendarSchedules* pSchedules = pData->GetSchedules();
  325. if (!pSchedules)
  326. return;
  327. if (pSchedules->GetCount() < 1)
  328. {
  329. pSchedules->AddNewSchedule(_T("John"));
  330. pSchedules->AddNewSchedule(_T("Jane"));
  331. }
  332. // ** resources
  333. CXTPCalendarResources arResources;
  334. CXTPCalendarResource* pRes0 = new CXTPCalendarResource(pCalendar);
  335. if (pRes0)
  336. {
  337. pRes0->SetName(_T("John"));
  338. pRes0->SetDataProvider(pData, TRUE);
  339. pRes0->GetSchedules()->Add(pSchedules->GetAt(0)->GetID());
  340. arResources.Add(pRes0);
  341. }
  342. CXTPCalendarResource* pRes1 = new CXTPCalendarResource(pCalendar);
  343. if (pRes1)
  344. {
  345. pRes1->SetName(_T("Jane (TimeZone: +8)"));
  346. pRes1->SetDataProvider(pData);
  347. pRes1->GetSchedules()->Add(pSchedules->GetAt(1)->GetID());
  348. arResources.Add(pRes1);
  349. }
  350. pCalendar->SetResources(&arResources);
  351. // Add sample events
  352. int nRes = AfxMessageBox(_T("Would You like to add default test events set?"), MB_YESNO);
  353. if (nRes == IDYES) 
  354. {
  355. pData->RemoveAllEvents();
  356. CCalendarDemoDoc::AddTestEvents(pData, COleDateTimeSpan(0), pSchedules->GetAt(0)->GetID());
  357. CCalendarDemoDoc::AddTestEvents(pData, COleDateTimeSpan(0, 8, 0, 0), pSchedules->GetAt(1)->GetID());
  358. if (!pData->Save()) 
  359. AfxMessageBox(_T("Memory data provider cannot save document"));
  360. }
  361. // Save and apply changed resources configuration
  362. pCalendar->Populate();
  363. pCalendar->RedrawControl();
  364. // Update Sample caption
  365. pDemoView->GetDocument()->CDocument::SetTitle(_T("Multiple Schedules sample N1"));
  366. // Cleanup
  367. CMDTARGET_RELEASE(pData);
  368. }
  369. // Create an extended Multiple Schedules sample configuration using 
  370. // a sample CXTPCalendarResourcesManager class.
  371. void CCalendarDemoApp::OnMultiSchedulesSampleExt()
  372. {
  373. // Get Calendar pointer
  374. CCalendarDemoView* pDemoView = GetCalendarDemoView();
  375. if(!pDemoView)
  376. return;
  377. CXTPCalendarControl* pCalendar = &pDemoView->GetCalendarCtrl();
  378. // Prepare resource manager
  379. CString strCfgFile = GetModulePath() +_T("CalendarMultipleSchedulesSample.xml");
  380. if (!m_pCalRCman)
  381. {
  382. m_pCalRCman = new CXTPCalendarResourcesManager();
  383. if (!m_pCalRCman)
  384. return;
  385. //m_pCalRCman->LoadCfg(strCfgFile);
  386. }
  387. // Setup sample configuration
  388. // ** data provider
  389. CString strConnectionString = _T("Provider=XML;Data Source=") + 
  390. GetModulePath() + _T("CalendarMultipleSchedulesExt.xtp_cal");
  391. m_pCalRCman->AddDataProvider(strConnectionString, 
  392. CXTPCalendarResourcesManager::xtpCalendarDPF_CreateIfNotExists |
  393. CXTPCalendarResourcesManager::xtpCalendarDPF_SaveOnDestroy |
  394. CXTPCalendarResourcesManager::xtpCalendarDPF_CloseOnDestroy);
  395. if (m_pCalRCman->GetDataProvidersCount() < 1)
  396. return;
  397. CXTPCalendarData* pData = m_pCalRCman->GetDataProvider(0);
  398. if (!pData)
  399. return;
  400. // ** schedules
  401. CXTPCalendarSchedules* pSchedules = pData->GetSchedules();
  402. if (!pSchedules)
  403. return;
  404. if (pSchedules->GetCount() == 0)
  405. {
  406. pSchedules->AddNewSchedule(_T("John"));
  407. pSchedules->AddNewSchedule(_T("Peter"));
  408. pSchedules->AddNewSchedule(_T("Conference Room N1"));
  409. pSchedules->AddNewSchedule(_T("Conference Room N2"));
  410. }
  411. // ** resources
  412. m_pCalRCman->AddResource(_T("John"), TRUE);
  413. m_pCalRCman->AddResource(_T("Peter"), TRUE);
  414. m_pCalRCman->AddResource(_T("Rooms"), TRUE);
  415. CXTPCalendarResourceDescription* pRCDesc = m_pCalRCman->GetResource(0);
  416. if (pRCDesc && pRCDesc->m_ptrResource)
  417. {
  418. pRCDesc->m_ptrResource->SetDataProvider(pData);
  419. pRCDesc->m_ptrResource->GetSchedules()->Add(pSchedules->GetAt(0)->GetID());
  420. pRCDesc->m_bGenerateName = TRUE;
  421. }
  422. pRCDesc = m_pCalRCman->GetResource(1);
  423. if (pRCDesc && pRCDesc->m_ptrResource)
  424. {
  425. pRCDesc->m_ptrResource->SetDataProvider(pData);
  426. pRCDesc->m_ptrResource->GetSchedules()->Add(pSchedules->GetAt(1)->GetID());
  427. pRCDesc->m_bGenerateName = TRUE;
  428. }
  429. pRCDesc = m_pCalRCman->GetResource(2);
  430. if (pRCDesc && pRCDesc->m_ptrResource)
  431. {
  432. pRCDesc->m_ptrResource->SetDataProvider(pData);
  433. pRCDesc->m_ptrResource->GetSchedules()->Add(pSchedules->GetAt(2)->GetID());
  434. pRCDesc->m_ptrResource->GetSchedules()->Add(pSchedules->GetAt(3)->GetID());
  435. pRCDesc->m_bGenerateName = FALSE;
  436. }
  437. // Save and apply changed resources configuration
  438. m_pCalRCman->SaveCfg(strCfgFile);
  439. m_pCalRCman->ApplyToCalendar(pCalendar);
  440. pCalendar->Populate();
  441. pCalendar->RedrawControl();
  442. // Update Sample caption
  443. pDemoView->GetDocument()->CDocument::SetTitle(_T("Multiple Schedules sample N2"));
  444. // Cleanup
  445. }
  446. ////////////////////////////////////////////////////////////////////////////
  447. // CCalendarInternalOptions dialog
  448. //
  449. IMPLEMENT_DYNAMIC(CCalendarInternalOptions, CDialog)
  450. CCalendarInternalOptions::CCalendarInternalOptions(CXTPCalendarData* pCData, CWnd* pParent /*=NULL*/)
  451. : CDialog(CCalendarInternalOptions::IDD, pParent)
  452. {
  453. ASSERT(pCData);
  454. m_ptrCData = pCData;
  455. }
  456. CCalendarInternalOptions::~CCalendarInternalOptions()
  457. {
  458. }
  459. void CCalendarInternalOptions::DoDataExchange(CDataExchange* pDX)
  460. {
  461. CDialog::DoDataExchange(pDX);
  462. DDX_Control(pDX, IDC_DBDP_CACHE_MODE_CB, m_ctrlDBDPCacheModeCb);
  463. DDX_Control(pDX, IDC_DBDP_CACHE_MODE_COMMENT, m_ctrlDBDPCacheModeComment);
  464. }
  465. BEGIN_MESSAGE_MAP(CCalendarInternalOptions, CDialog)
  466. ON_BN_CLICKED(IDOK, OnBnClickedOk)
  467. END_MESSAGE_MAP()
  468. BOOL CCalendarInternalOptions::OnInitDialog()
  469. {
  470. CDialog::OnInitDialog();
  471. if(!m_ptrCData) 
  472. {
  473. ASSERT(FALSE);
  474. return FALSE;
  475. }
  476. //===========================================================================
  477. BOOL bSupported_DBDPCacheMode = m_ptrCData->GetType() != xtpCalendarDataProviderMemory;
  478. int eDBDPCacheMode = m_ptrCData->GetCacheMode();
  479. int nIdx = m_ctrlDBDPCacheModeCb.AddString(_T("OFF"));
  480. m_ctrlDBDPCacheModeCb.SetItemData(nIdx, xtpCalendarDPCacheModeOff);
  481. nIdx = m_ctrlDBDPCacheModeCb.AddString(_T("ON, Repeat manipulations (Default)"));
  482. m_ctrlDBDPCacheModeCb.SetItemData(nIdx, xtpCalendarDPCacheModeOnRepeat);
  483. nIdx = m_ctrlDBDPCacheModeCb.AddString(_T("ON, Clear after manipulations"));
  484. m_ctrlDBDPCacheModeCb.SetItemData(nIdx, xtpCalendarDPCacheModeOnClear);
  485. for(int i = 0; i < m_ctrlDBDPCacheModeCb.GetCount(); i++) 
  486. {
  487. if((int)m_ctrlDBDPCacheModeCb.GetItemData(i) == eDBDPCacheMode) 
  488. {
  489. m_ctrlDBDPCacheModeCb.SetCurSel(i);
  490. break;
  491. }
  492. }
  493.     
  494. m_ctrlDBDPCacheModeCb.EnableWindow(bSupported_DBDPCacheMode);
  495. //if(GetDlgItem(IDC_DBDP_CACHE_MODE_FRAME)) {
  496. // GetDlgItem(IDC_DBDP_CACHE_MODE_FRAME)->EnableWindow(bSupported_DBDPCacheMode);
  497. //}
  498. if(GetDlgItem(IDC_DBDP_CACHE_MODE_LABEL)) {
  499. GetDlgItem(IDC_DBDP_CACHE_MODE_LABEL)->EnableWindow(bSupported_DBDPCacheMode);
  500. }
  501. if(GetDlgItem(IDOK)) {
  502. GetDlgItem(IDOK)->EnableWindow(bSupported_DBDPCacheMode);
  503. }
  504. if(!bSupported_DBDPCacheMode) {
  505. m_ctrlDBDPCacheModeComment.SetWindowText(_T("Is not supported. Switch to DB Data provider"));
  506. }
  507. return TRUE;
  508. }
  509. /////////////////////////////////////////////////////////////////////////////
  510. // CCalendarDemoApp message handlers
  511. void CCalendarInternalOptions::OnBnClickedOk()
  512. {
  513. ASSERT(m_ptrCData);
  514. if(m_ptrCData) 
  515. {
  516. int nSel = m_ctrlDBDPCacheModeCb.GetCurSel();
  517. if(nSel != CB_ERR) 
  518. {
  519. int eCMode = (int)m_ctrlDBDPCacheModeCb.GetItemData(nSel);
  520. ASSERT( eCMode == xtpCalendarDPCacheModeOff ||
  521. eCMode == xtpCalendarDPCacheModeOnRepeat ||
  522. eCMode == xtpCalendarDPCacheModeOnClear );
  523. m_ptrCData->SetCacheMode(eCMode);
  524. }
  525. }
  526. OnOK();
  527. }