home *** CD-ROM | disk | FTP | other *** search
/ Computer Buyer 1998 October / dpcb1098.iso / Business / Maxim / MAX5 / data.z / WizPages.cpp < prev    next >
C/C++ Source or Header  |  1998-05-15  |  35KB  |  1,143 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. // NAME.......: WizPages.CPP                                               
  3. // PURPOSE....: implementation of wizard pages 
  4. // WRITTEN....: 96/09/27 by Darko Juvan
  5. // DESCRIPTION: implementation    of 4 wizard property pages
  6. //
  7. // This code and information is provided "as is" without warranty of any
  8. // kind, either expressed or implied, including but not limited to the
  9. // implied warranties of merchantability and/or fitness for a particular
  10. // purpose..
  11. //
  12. // Copyright (c) 1998  Multiactive Software Inc.  All Rights Reserved.
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15.  
  16. #include "stdafx.h"
  17. #include "WizPages.h"
  18. #include "MaxInterface.h"
  19.  
  20.  
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26.  
  27. extern IMaxApp*     g_pApplication;
  28. extern ICurrentRec* g_pCurrentRecord;
  29.  
  30. extern void SetAppResources();
  31. extern void SetDllResources();
  32.  
  33. #define ID_TIME1  2001
  34. #define ID_TIME2  2002
  35.  
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CPage1 property page
  38.  
  39. IMPLEMENT_DYNCREATE(CPage1, CWizPropertyPage)
  40.  
  41. //////////////////////////////////////////////////////////////////////////////
  42. //                        
  43. // FUNCTION...: CPage1()
  44. //                                                  
  45. // DESCRIPTION: constructor
  46. //
  47. //////////////////////////////////////////////////////////////////////////////
  48. CPage1::CPage1() : CWizPropertyPage(CPage1::IDD)
  49. {
  50.     //{{AFX_DATA_INIT(CPage1)
  51.         // NOTE: the ClassWizard will add member initialization here
  52.     //}}AFX_DATA_INIT
  53. }
  54.  
  55. //////////////////////////////////////////////////////////////////////////////
  56. //                        
  57. // FUNCTION...: CPage1()
  58. //                                                  
  59. // DESCRIPTION: constructor
  60. //
  61. //////////////////////////////////////////////////////////////////////////////
  62. CPage1::CPage1(CWizPropertySheet* pWizSheet) 
  63. : CWizPropertyPage(pWizSheet, CPage1::IDD)
  64. {
  65.     //pointer to CWizPropertySheet
  66.     m_pWizSheet = pWizSheet;
  67. }
  68.  
  69. //////////////////////////////////////////////////////////////////////////////
  70. //                        
  71. // FUNCTION...: ~CPage1()
  72. //                                                  
  73. // DESCRIPTION: destructor
  74. //
  75. //////////////////////////////////////////////////////////////////////////////
  76. CPage1::~CPage1()
  77. {
  78. }
  79.  
  80. //////////////////////////////////////////////////////////////////////////////
  81. //                        
  82. // FUNCTION...: DoDataExchange()
  83. //                                                  
  84. // DESCRIPTION: MFC
  85. //
  86. //////////////////////////////////////////////////////////////////////////////
  87. void CPage1::DoDataExchange(CDataExchange* pDX)
  88. {
  89.     CWizPropertyPage::DoDataExchange(pDX);
  90.     //{{AFX_DATA_MAP(CPage1)
  91.         // NOTE: the ClassWizard will add DDX and DDV calls here
  92.     //}}AFX_DATA_MAP
  93. }
  94.  
  95.  
  96. BEGIN_MESSAGE_MAP(CPage1, CWizPropertyPage)
  97.     //{{AFX_MSG_MAP(CPage1)
  98.     ON_WM_CTLCOLOR()
  99.     ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
  100.     ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
  101.     ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
  102.     //}}AFX_MSG_MAP
  103. END_MESSAGE_MAP()
  104. /////////////////////////////////////
  105. // CPage1 message handlers
  106.  
  107. //////////////////////////////////////////////////////////////////////////////
  108. //                        
  109. // FUNCTION...: OnInitDialog()
  110. //                                                  
  111. // DESCRIPTION: MFC
  112. //
  113. //////////////////////////////////////////////////////////////////////////////
  114. BOOL CPage1::OnInitDialog() 
  115. {
  116.     CWizPropertyPage::OnInitDialog();
  117.     CString company;
  118.     CString first;
  119.     CString last;
  120.     CString str;
  121.     CString str2;
  122.     BOOL bPersonal = FALSE;
  123.  
  124.     BOOL bCompany = FALSE;
  125.     BOOL bNoCurRecord = FALSE;
  126.  
  127.     //set app resources cause we are calling 
  128.     //Maximizer function and resource pointer 
  129.     //should point to application resoures
  130.     SetAppResources();
  131.  
  132.     //check if you can get First Name
  133.     first = g_pCurrentRecord->GetFieldValue("First_Name");
  134.     if( first == "Error0")
  135.         bNoCurRecord = TRUE;
  136.  
  137.     if(!bNoCurRecord)
  138.     {
  139.  
  140.         //check for Last Name
  141.         last = g_pCurrentRecord->GetFieldValue("Last_Name");
  142.  
  143.  
  144.         //if First and Last are empty it's Company record
  145.         if(first.IsEmpty() && last.IsEmpty())
  146.         {
  147.             bCompany = TRUE;
  148.             company = g_pCurrentRecord->GetFieldValue("Company");
  149.             if(company.IsEmpty())
  150.                 //and if Company Name is empty there's no current record
  151.                 bNoCurRecord = TRUE;
  152.         }
  153.  
  154.     }
  155.  
  156.     //return to dll resources
  157.     SetDllResources();
  158.  
  159.     //"...personal appointment."
  160.     m_text1.LoadString(S13);
  161.     
  162.     if(bNoCurRecord)
  163.     {
  164.         //there's no current record
  165.         m_pWizSheet->m_personal = 0;
  166.  
  167.         //set summary text
  168.         m_pWizSheet->m_text1 = m_text1;
  169.  
  170.         //change text of 2nd btn -> "No current record in Address Book"
  171.         str.LoadString(S1111);
  172.         GetDlgItem(IDC_RADIO2)->SetWindowText(str);
  173.         //disable 2 btn (no current record)
  174.         ((CButton*)GetDlgItem(IDC_RADIO2))->EnableWindow(FALSE);
  175.         //set default (1) radio btn (personal appointment)
  176.         ((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(1);
  177.     }
  178.     else
  179.     {
  180.         //set default (2) radio btn 
  181.         ((CButton*)GetDlgItem(IDC_RADIO2))->SetCheck(1);
  182.  
  183.         //"...with"
  184.         str.LoadString(S12);
  185.         
  186.         //format text for summary text
  187.         if(bCompany)
  188.             m_text2.Format("%s %s.", str, company);
  189.         else
  190.             m_text2.Format("%s %s %s.", str, first, last);
  191.  
  192.         m_pWizSheet->m_text1 = m_text2;
  193.         m_pWizSheet->m_personal = 1;
  194.  
  195.         //format text for radio btn 2
  196.         str.LoadString(S15);
  197.         if(bCompany)
  198.             str2.Format("%s %s.", str, company);
  199.         else
  200.             str2.Format("%s %s %s", str, first, last);
  201.  
  202.         //change text for radio btn 2
  203.         GetDlgItem(IDC_RADIO2)->SetWindowText(str2);
  204.     }
  205.  
  206.      
  207.     //set text for summary  line 1
  208.     GetDlgItem(IDC_STATIC_1)->SetWindowText(m_pWizSheet->m_text1);
  209.  
  210.     return TRUE;  // return TRUE unless you set the focus to a control
  211.                   // EXCEPTION: OCX Property Pages should return FALSE
  212. }
  213.  
  214.  
  215. //////////////////////////////////////////////////////////////////////////////
  216. //                        
  217. // FUNCTION...: OnRadio1()
  218. //                                                  
  219. // DESCRIPTION: radio button was clicked
  220. //
  221. //////////////////////////////////////////////////////////////////////////////
  222. void CPage1::OnRadio1() 
  223. {
  224.     //change summary text
  225.     SetDlgItemText(IDC_STATIC_1, m_text1);
  226.     m_pWizSheet->m_text1 = m_text1;
  227.     m_pWizSheet->m_personal = 0;
  228.  
  229.     //enable NEXT button
  230.     m_pWizSheet->GetDlgItem(ID_WIZNEXT)->EnableWindow(TRUE);
  231.     //erase warning (on radio btn 3)
  232.     SetDlgItemText(IDC_STATIC_ERROR, "");
  233.     
  234. }
  235.  
  236. //////////////////////////////////////////////////////////////////////////////
  237. //                        
  238. // FUNCTION...: OnRadio2()
  239. //                                                  
  240. // DESCRIPTION: radio button was clicked
  241. //
  242. //////////////////////////////////////////////////////////////////////////////
  243. void CPage1::OnRadio2() 
  244. {
  245.     //change summary text
  246.     GetDlgItem(IDC_STATIC_1)->SetWindowText(m_text2);
  247.     m_pWizSheet->m_text1 = m_text2;
  248.     m_pWizSheet->m_personal = 1;
  249.  
  250.     //enable NEXT button
  251.     m_pWizSheet->GetDlgItem(ID_WIZNEXT)->EnableWindow(TRUE);
  252.     //erase warning (on radio btn 3)
  253.     SetDlgItemText(IDC_STATIC_ERROR, "");
  254.     
  255. }
  256.  
  257. //////////////////////////////////////////////////////////////////////////////
  258. //                        
  259. // FUNCTION...: OnRadio3()
  260. //                                                  
  261. // DESCRIPTION: radio button was clicked
  262. //
  263. //////////////////////////////////////////////////////////////////////////////
  264. void CPage1::OnRadio3() 
  265. {
  266.     CString str;
  267.  
  268.     //issue warning
  269.     str.LoadString(S14);
  270.     GetDlgItem(IDC_STATIC_ERROR)->SetWindowText(str);
  271.     GetDlgItem(IDC_STATIC_1)->SetWindowText("");
  272.  
  273.     //disable NEXT button
  274.     m_pWizSheet->GetDlgItem(ID_WIZNEXT)->EnableWindow(FALSE);
  275.  
  276.  
  277. }
  278.  
  279. //////////////////////////////////////////////////////////////////////////////
  280. //                        
  281. // FUNCTION...: OnSetActive()
  282. //                                                  
  283. // DESCRIPTION: MFC - page is getting active
  284. //
  285. //////////////////////////////////////////////////////////////////////////////
  286. BOOL CPage1::OnSetActive() 
  287. {
  288.     m_pWizSheet->GetDlgItem(ID_WIZBACK)->EnableWindow(FALSE);
  289.     m_pWizSheet->GetDlgItem(IDHELP)->EnableWindow(FALSE);
  290.     m_pWizSheet->GetDlgItem(IDHELP)->ShowWindow(SW_HIDE);
  291.     
  292.     return CWizPropertyPage::OnSetActive();
  293. }
  294.  
  295. //////////////////////////////////////////////////////////////////////////////
  296. //                        
  297. // FUNCTION...: OnKillActive()
  298. //                                                  
  299. // DESCRIPTION: MFC - page is losing active state
  300. //
  301. //////////////////////////////////////////////////////////////////////////////
  302. BOOL CPage1::OnKillActive() 
  303. {
  304.     m_pWizSheet->GetDlgItem(ID_WIZBACK)->EnableWindow(TRUE);
  305.     
  306.     return CWizPropertyPage::OnKillActive();
  307. }
  308.  
  309. /////////////////////////////////////////////////////////////////////////////
  310. // CPage2 property page
  311. IMPLEMENT_DYNCREATE(CPage2, CWizPropertyPage)
  312.  
  313. //////////////////////////////////////////////////////////////////////////////
  314. //                        
  315. // FUNCTION...: CPage2()
  316. //                                                  
  317. // DESCRIPTION: constructor
  318. //
  319. //////////////////////////////////////////////////////////////////////////////
  320. CPage2::CPage2() : CWizPropertyPage(CPage2::IDD)
  321. {
  322. }
  323.  
  324. //////////////////////////////////////////////////////////////////////////////
  325. //                        
  326. // FUNCTION...: CPage2()
  327. //                                                  
  328. // DESCRIPTION: constructor
  329. //
  330. //////////////////////////////////////////////////////////////////////////////
  331. CPage2::CPage2(CWizPropertySheet* pWizSheet) 
  332. : CWizPropertyPage(pWizSheet, CPage2::IDD)
  333. {
  334.     //pointer to CWizPropertySheet
  335.     m_pWizSheet = pWizSheet;
  336. }
  337.  
  338. //////////////////////////////////////////////////////////////////////////////
  339. //                        
  340. // FUNCTION...: ~CPage2()
  341. //                                                  
  342. // DESCRIPTION: destructor
  343. //
  344. //////////////////////////////////////////////////////////////////////////////
  345. CPage2::~CPage2()
  346. {
  347. }
  348.  
  349. //////////////////////////////////////////////////////////////////////////////
  350. //                        
  351. // FUNCTION...: DoDataExchange()
  352. //                                                  
  353. // DESCRIPTION: MFC
  354. //
  355. //////////////////////////////////////////////////////////////////////////////
  356. void CPage2::DoDataExchange(CDataExchange* pDX)
  357. {
  358.     CWizPropertyPage::DoDataExchange(pDX);
  359.     //{{AFX_DATA_MAP(CPage2)
  360.         // NOTE: the ClassWizard will add DDX and DDV calls here
  361.     //}}AFX_DATA_MAP
  362. }
  363.  
  364.  
  365. BEGIN_MESSAGE_MAP(CPage2, CWizPropertyPage)
  366.     //{{AFX_MSG_MAP(CPage2)
  367.     ON_MESSAGE( UM_DATE_CHANGED, OnDateChanged )
  368.     //}}AFX_MSG_MAP
  369. END_MESSAGE_MAP()
  370.  
  371. /////////////////////////////////////
  372. // CPage2 message handlers
  373.  
  374. //////////////////////////////////////////////////////////////////////////////
  375. //                        
  376. // FUNCTION...: OnInitDialog()
  377. //                                                  
  378. // DESCRIPTION: MFC
  379. //
  380. //////////////////////////////////////////////////////////////////////////////
  381. BOOL CPage2::OnInitDialog() 
  382. {
  383.     CWizPropertyPage::OnInitDialog();
  384.     CString str;
  385.  
  386.     //create Calendar ctrl
  387.     m_calendar.Create(this, IDC_DATE_DAY, IDC_DATE_MONTH, IDC_DATE_SPIN, m_iYear, m_iMonth, m_iDay);
  388.     
  389.     //initialize common ctrls
  390.     INITCOMMONCONTROLSEX iccex;
  391.     iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  392.     iccex.dwICC = ICC_DATE_CLASSES;
  393.     BOOL b = InitCommonControlsEx(&iccex);
  394.  
  395.     //create two time ctrls for start and end time
  396.     m_time1.Create(FALSE, this, IDC_TIMEX1, ID_TIME1); 
  397.     m_time2.Create(FALSE, this, IDC_TIMEX2, ID_TIME2); 
  398.     m_time1.SetTime(9,30,0);
  399.     m_time2.SetTime(9,30,0);
  400.     
  401.     //update summary info
  402.     OnTimeChanged();
  403.  
  404.     //update summary info
  405.     OnDateChanged(0,0);
  406.     
  407.     return TRUE;  // return TRUE unless you set the focus to a control
  408.                   // EXCEPTION: OCX Property Pages should return FALSE
  409. }
  410.  
  411. //////////////////////////////////////////////////////////////////////////////
  412. //                        
  413. // FUNCTION...: OnSetActive()
  414. //                                                  
  415. // DESCRIPTION: MFC - page is getting active
  416. //
  417. //////////////////////////////////////////////////////////////////////////////
  418. BOOL CPage2::OnSetActive() 
  419. {
  420.     GetDlgItem(IDC_STATIC_1)->SetWindowText(m_pWizSheet->m_text1);
  421.     
  422.     return CWizPropertyPage::OnSetActive();
  423. }
  424.  
  425. //////////////////////////////////////////////////////////////////////////////
  426. //                        
  427. // FUNCTION...: PreTranslateMessage()
  428. //                                                  
  429. // DESCRIPTION: MFC - forward msg to calendar ctrl
  430. //
  431. //////////////////////////////////////////////////////////////////////////////
  432. BOOL CPage2::PreTranslateMessage(MSG* pMsg) 
  433. {
  434.     m_calendar.ForwardMsg(pMsg);    
  435.     return CWizPropertyPage::PreTranslateMessage(pMsg);
  436. }
  437.  
  438. //////////////////////////////////////////////////////////////////////////////
  439. //                        
  440. // FUNCTION...: OnDateChanged()
  441. //                                                  
  442. // DESCRIPTION: notification from calendar ctrl
  443. //
  444. //////////////////////////////////////////////////////////////////////////////
  445. LONG CPage2::OnDateChanged(UINT wParam, LONG lParam)
  446. {
  447.     m_calendar.RefreshDate();
  448.  
  449.     //set a proper month
  450.     CString sMonth;
  451.     switch(m_calendar.m_iMonth)
  452.     {
  453.         case 1:    
  454.  
  455.                 sMonth.LoadString(SM1);
  456.                 break;
  457.         case 2:    
  458.                 sMonth.LoadString(SM2); 
  459.                 break;
  460.         case 3:    
  461.                 sMonth.LoadString(SM3); 
  462.                 break;
  463.         case 4:    
  464.                 sMonth.LoadString(SM4); 
  465.                 break;
  466.         case 5: 
  467.                 sMonth.LoadString(SM5); 
  468.                 break;
  469.         case 6:    
  470.                 sMonth.LoadString(SM6); 
  471.                 break;
  472.         case 7:    
  473.                 sMonth.LoadString(SM7); 
  474.                 break;
  475.         case 8:    
  476.                 sMonth.LoadString(SM8); 
  477.                 break;
  478.         case 9:    
  479.                 sMonth.LoadString(SM9); 
  480.                 break;
  481.         case 10:
  482.                 sMonth.LoadString(SM10); 
  483.                 break;
  484.         case 11:
  485.                 sMonth.LoadString(SM11); 
  486.                 break;
  487.         case 12:
  488.                 sMonth.LoadString(SM12); 
  489.     }
  490.     
  491.     //date has changed - update
  492.     CString str;
  493.     str.Format("%s %d, %d", sMonth, m_calendar.m_iDay, m_calendar.m_iYear);
  494.     
  495.     CString str2;
  496.     str2.LoadString(S21);
  497.  
  498.     m_pWizSheet->m_text2.Format("%s %s.", str2, str);
  499.     m_pWizSheet->m_date = str;
  500.     SetDlgItemText(IDC_STATIC_2, m_pWizSheet->m_text2);
  501.  
  502.     return 1L;
  503. }
  504.  
  505. //////////////////////////////////////////////////////////////////////////////
  506. //                        
  507. // FUNCTION...: OnNotify()
  508. //                                                  
  509. // DESCRIPTION: Time ctrl notify
  510. //
  511. //////////////////////////////////////////////////////////////////////////////
  512. BOOL CPage2::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
  513. {
  514.     NMHDR*  pNmhdr;
  515.     NMDATETIMECHANGE* pnm = (NMDATETIMECHANGE*)lParam;
  516.     pNmhdr = (NMHDR*)lParam;
  517.     if(pNmhdr->code == DTN_DATETIMECHANGE)
  518.         if(pNmhdr->idFrom == ID_TIME1 || pNmhdr->idFrom == ID_TIME2)
  519.             //time has changed - update
  520.             OnTimeChanged();
  521.  
  522.     return CWizPropertyPage::OnNotify(wParam, lParam, pResult);
  523. }
  524.  
  525. //////////////////////////////////////////////////////////////////////////////
  526. //                        
  527. // FUNCTION...: OnTimeChanged()
  528. //                                                  
  529. // DESCRIPTION: notification from time ctrl
  530. //
  531. //////////////////////////////////////////////////////////////////////////////
  532. void CPage2::OnTimeChanged()
  533. {
  534.     //time has changed - update
  535.     CString sTime1 = m_time1.GetTime(&m_Time1);
  536.     CString sTime2 = m_time2.GetTime(&m_Time2);
  537.     m_pWizSheet->m_time1 = sTime1;
  538.     m_pWizSheet->m_time2 = sTime2;
  539.  
  540.     AfxFormatString2(m_pWizSheet->m_text3, S22, m_pWizSheet->m_time1, m_pWizSheet->m_time2);  
  541.     SetDlgItemText(IDC_STATIC_3, m_pWizSheet->m_text3);
  542. }
  543.  
  544. //////////////////////////////////////////////////////////////////////////////
  545. //                        
  546. // FUNCTION...: OnWizardNext()
  547. //                                                  
  548. // DESCRIPTION: MFC - next button is pressed
  549. //
  550. //////////////////////////////////////////////////////////////////////////////
  551. LRESULT CPage2::OnWizardNext() 
  552. {
  553.     //issue warning if m_Time1 > m_Time2
  554.     if(m_Time1 > m_Time2)
  555.     {
  556.         CString str;
  557.         str.LoadString(S1112);
  558.         if(AfxMessageBox(str, MB_YESNO) == IDYES)
  559.         {
  560.             m_pWizSheet->m_time2 = m_pWizSheet->m_time1;
  561.             AfxFormatString2(m_pWizSheet->m_text3, S22, m_pWizSheet->m_time1, m_pWizSheet->m_time2);  
  562.             SetDlgItemText(IDC_STATIC_3, m_pWizSheet->m_text3);
  563.             m_Time2 = m_Time1;
  564.             m_time2.SetTime(m_Time1.GetHour(), m_Time1.GetMinute(), m_Time1.GetSecond());
  565.             return CWizPropertyPage::OnWizardNext();
  566.         }
  567.         else
  568.             return (-1);
  569.     }
  570.     
  571.     return CWizPropertyPage::OnWizardNext();
  572. }
  573.  
  574. //////////////////////////////////////////////////////////////////////////////
  575. //                        
  576. // FUNCTION...: OnKillActive()
  577. //                                                  
  578. // DESCRIPTION: MFC - page is losing active state
  579. //
  580. //////////////////////////////////////////////////////////////////////////////
  581. BOOL CPage2::OnKillActive() 
  582. {
  583.     return CWizPropertyPage::OnKillActive();
  584. }
  585.  
  586.  
  587. /////////////////////////////////////////////////////////////////////////////
  588. // CPage3 property page
  589.  
  590. IMPLEMENT_DYNCREATE(CPage3, CWizPropertyPage)
  591.  
  592. //////////////////////////////////////////////////////////////////////////////
  593. //                        
  594. // FUNCTION...: CPage3()
  595. //                                                  
  596. // DESCRIPTION: constructor
  597. //
  598. //////////////////////////////////////////////////////////////////////////////
  599. CPage3::CPage3() : CWizPropertyPage(CPage3::IDD)
  600. {
  601. }
  602. //////////////////////////////////////////////////////////////////////////////
  603. //                        
  604. // FUNCTION...: CPage3()
  605. //                                                  
  606. // DESCRIPTION: constructor
  607. //
  608. //////////////////////////////////////////////////////////////////////////////
  609. CPage3::CPage3(CWizPropertySheet* pWizSheet) 
  610. : CWizPropertyPage(pWizSheet, CPage3::IDD)
  611. {
  612.     //pointer to CWizPropertySheet
  613.     m_pWizSheet = pWizSheet;
  614. }
  615.  
  616. //////////////////////////////////////////////////////////////////////////////
  617. //                        
  618. // FUNCTION...: ~CPage3()
  619. //                                                  
  620. // DESCRIPTION: destructor
  621. //
  622. //////////////////////////////////////////////////////////////////////////////
  623. CPage3::~CPage3()
  624. {
  625. }
  626.  
  627. //////////////////////////////////////////////////////////////////////////////
  628. //                        
  629. // FUNCTION...: DoDataExchange()
  630. //                                                  
  631. // DESCRIPTION: MFC
  632. //
  633. //////////////////////////////////////////////////////////////////////////////
  634. void CPage3::DoDataExchange(CDataExchange* pDX)
  635. {
  636.     CWizPropertyPage::DoDataExchange(pDX);
  637.     //{{AFX_DATA_MAP(CPage3)
  638.         // NOTE: the ClassWizard will add DDX and DDV calls here
  639.     //}}AFX_DATA_MAP
  640. }
  641.  
  642.  
  643. BEGIN_MESSAGE_MAP(CPage3, CWizPropertyPage)
  644.     //{{AFX_MSG_MAP(CPage3)
  645.     ON_CBN_SELCHANGE(IDC_COMBO_ACTIVITY, OnSelchangeComboActivity)
  646.     ON_CBN_SELCHANGE(IDC_COMBO_PRIORITY, OnSelchangeComboPriority)
  647.     ON_CBN_EDITCHANGE(IDC_COMBO_ALARM, OnEditchangeComboAlarm)
  648.     ON_CBN_SELCHANGE(IDC_COMBO_ALARM, OnSelchangeComboAlarm)
  649.     ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
  650.     ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
  651.     ON_EN_UPDATE(IDC_EDIT_ACTIVITY, OnUpdateEditActivity)
  652.     //}}AFX_MSG_MAP
  653. END_MESSAGE_MAP()
  654.  
  655. /////////////////////////////////////
  656. // CPage3 message handlers
  657.  
  658.  
  659.  
  660. //////////////////////////////////////////////////////////////////////////////
  661. //                        
  662. // FUNCTION...: OnInitDialog()
  663. //                                                  
  664. // DESCRIPTION: MFC
  665. //
  666. //////////////////////////////////////////////////////////////////////////////
  667. BOOL CPage3::OnInitDialog() 
  668. {
  669.     CWizPropertyPage::OnInitDialog();
  670.     
  671.     //set default alarm btns
  672.     ((CButton*)GetDlgItem(IDC_RADIO2))->SetCheck(1);
  673.     ((CComboBox*)GetDlgItem(IDC_COMBO_ALARM))->LimitText(3);
  674.     ((CComboBox*)GetDlgItem(IDC_COMBO_ALARM))->SetCurSel(2);
  675.     OnRadio2();
  676.  
  677.     //set default priority
  678.     ((CComboBox*)GetDlgItem(IDC_COMBO_PRIORITY))->SetCurSel(0);
  679.  
  680.     //subclass owner drawn combo - activity type combo
  681.     m_combo.SubclassDlgItem (IDC_COMBO_ACTIVITY, this);
  682.  
  683.     CString str;
  684.     str.LoadString(S391);
  685.     m_combo.AddItem(str, IDB_MEETING);
  686.     str.LoadString(S392);
  687.     m_combo.AddItem(str, IDB_PHONE);
  688.     str.LoadString(S393);
  689.     m_combo.AddItem(str, IDB_TODO);
  690.     str.LoadString(S394);
  691.     m_combo.AddItem(str, IDB_MEAL);
  692.     str.LoadString(S395);
  693.     m_combo.AddItem(str, IDB_TRAVEL);
  694.     str.LoadString(S396);
  695.     m_combo.AddItem(str, IDB_SALE);
  696.     str.LoadString(S397);
  697.     m_combo.AddItem(str, IDB_MAIL);
  698.     str.LoadString(S398);
  699.     m_combo.AddItem(str, IDB_SPEECH);
  700.     str.LoadString(S399);
  701.     m_combo.AddItem(str, IDB_PRESENTATION);
  702.  
  703.     //set default to meeting
  704.     m_combo.SetCurSel(0);
  705.  
  706.     //update
  707.     OnSelchangeComboActivity();
  708.     OnSelchangeComboPriority() ;
  709.  
  710.     GetDlgItem(IDC_EDIT_ACTIVITY)->SetFocus();
  711.     return FALSE;  // return TRUE unless you set the focus to a control
  712.                   // EXCEPTION: OCX Property Pages should return FALSE
  713. }
  714.  
  715. //////////////////////////////////////////////////////////////////////////////
  716. //                        
  717. // FUNCTION...: OnRadio1()
  718. //                                                  
  719. // DESCRIPTION: click on alarm radio button (Yes) 
  720. //
  721. //////////////////////////////////////////////////////////////////////////////
  722. void CPage3::OnRadio1() 
  723. {
  724.     if(((CButton*)GetDlgItem(IDC_RADIO1))->GetCheck())
  725.     {
  726.         CString str;
  727.         GetDlgItem(IDC_COMBO_ALARM)->EnableWindow(TRUE);
  728.         GetDlgItem(IDC_STATIC1)->EnableWindow(TRUE);
  729.         GetDlgItem(IDC_STATIC2)->EnableWindow(TRUE);
  730.         m_pWizSheet->m_alarm = 1;
  731.         GetDlgItem(IDC_COMBO_ALARM)->GetWindowText(str);
  732.         SetComboAlarm(str);
  733.     }
  734. }
  735.  
  736. //////////////////////////////////////////////////////////////////////////////
  737. //                        
  738. // FUNCTION...: OnRadio2()
  739. //                                                  
  740. // DESCRIPTION: click on alarm radio button (No) 
  741. //
  742. //////////////////////////////////////////////////////////////////////////////
  743. void CPage3::OnRadio2() 
  744. {
  745.     if(((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck())
  746.     {
  747.         GetDlgItem(IDC_COMBO_ALARM)->EnableWindow(FALSE);
  748.         GetDlgItem(IDC_STATIC1)->EnableWindow(FALSE);
  749.         GetDlgItem(IDC_STATIC2)->EnableWindow(FALSE);
  750.         m_pWizSheet->m_alarm = 0;
  751.         m_pWizSheet->m_text5.LoadString(S311);
  752.         SetDlgItemText(IDC_STATIC_5, m_pWizSheet->m_text5);
  753.     }
  754. }
  755.  
  756. //////////////////////////////////////////////////////////////////////////////
  757. //                        
  758. // FUNCTION...: GetActivity()
  759. //                                                  
  760. // DESCRIPTION: get activity text and bmp 
  761. //
  762. //////////////////////////////////////////////////////////////////////////////
  763. LPCTSTR CPage3::GetActivity(int sel)
  764. {
  765.     CString str;
  766.  
  767.     switch(sel)
  768.     {
  769.         case 0: str.LoadString(S391); 
  770.                 m_pWizSheet->m_iconType  = 9;
  771.                 m_pWizSheet->m_text  = str;
  772.                 break;
  773.         case 1: str.LoadString(S392); 
  774.                 m_pWizSheet->m_iconType  = 3;
  775.                 m_pWizSheet->m_text  = str;
  776.                 break;
  777.         case 2: str.LoadString(S393); 
  778.                 m_pWizSheet->m_iconType  = 2;
  779.                 m_pWizSheet->m_text  = str;
  780.                 break;
  781.         case 3: str.LoadString(S394); 
  782.                 m_pWizSheet->m_iconType  = 6;
  783.                 m_pWizSheet->m_text  = str;
  784.                 break;
  785.         case 4: str.LoadString(S395); 
  786.                 m_pWizSheet->m_iconType  = 4;
  787.                 m_pWizSheet->m_text  = str;
  788.                 break;
  789.         case 5: str.LoadString(S396); 
  790.                 m_pWizSheet->m_iconType  = 5;
  791.                 m_pWizSheet->m_text  = str;
  792.                 break;
  793.         case 6: str.LoadString(S397); 
  794.                 m_pWizSheet->m_iconType  = 1;
  795.                 m_pWizSheet->m_text  = str;
  796.                 break;
  797.         case 7: str.LoadString(S398); 
  798.                 m_pWizSheet->m_iconType  = 8;
  799.                 m_pWizSheet->m_text  = str;
  800.                 break;
  801.         case 8: str.LoadString(S399);
  802.                 m_pWizSheet->m_iconType  = 7;
  803.                 m_pWizSheet->m_text  = str;
  804.                 break;
  805.     }
  806.     return str;
  807. }
  808.  
  809.  
  810. //////////////////////////////////////////////////////////////////////////////
  811. //                        
  812. // FUNCTION...: OnSelchangeComboActivity()
  813. //                                                  
  814. // DESCRIPTION: selection was changed in activity combo box
  815. //
  816. //////////////////////////////////////////////////////////////////////////////
  817. void CPage3::OnSelchangeComboActivity() 
  818. {
  819.     m_pWizSheet->m_text = GetActivity(m_combo.GetCurSel());
  820.  
  821.     AfxFormatString1(m_pWizSheet->m_text4, S39, m_pWizSheet->m_text);
  822.     GetDlgItem(IDC_STATIC_4)->SetWindowText(m_pWizSheet->m_text4);
  823.     
  824. }
  825.  
  826. //////////////////////////////////////////////////////////////////////////////
  827. //                        
  828. // FUNCTION...: OnEditchangeComboAlarm() 
  829. //                                                  
  830. // DESCRIPTION: text was changed in alarm combo box
  831. //
  832. //////////////////////////////////////////////////////////////////////////////
  833. void CPage3::OnEditchangeComboAlarm() 
  834. {
  835.     if(((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck())
  836.         return;
  837.  
  838.     CString str;
  839.     GetDlgItem(IDC_COMBO_ALARM)->GetWindowText(str);
  840.     SetComboAlarm(str);
  841.     
  842. }
  843.  
  844. //////////////////////////////////////////////////////////////////////////////
  845. //                        
  846. // FUNCTION...: OnSelchangeComboAlarm()
  847. //                                                  
  848. // DESCRIPTION: selection was changed in alarm combo box
  849. //
  850. //////////////////////////////////////////////////////////////////////////////
  851. void CPage3::OnSelchangeComboAlarm() 
  852. {
  853.     if(((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck())
  854.         return;
  855.  
  856.     CString str;
  857.     int sel = ((CComboBox*)GetDlgItem(IDC_COMBO_ALARM))->GetCurSel();
  858.     switch(sel)
  859.     {
  860.         case 0: str = "0"; break;
  861.         case 1: str = "5"; break;
  862.         case 2: str = "10"; break;
  863.         case 3: str = "15"; break;
  864.         case 4: str = "20"; break;
  865.         case 5: str = "30"; break;
  866.         case 6: str = "45"; break;
  867.         case 7: str = "60"; break;
  868.         case 8: str = "90"; break;
  869.         case 9: str = "120"; break;
  870.     }
  871.  
  872.     SetComboAlarm(str);
  873.     
  874. }
  875.  
  876. //////////////////////////////////////////////////////////////////////////////
  877. //                        
  878. // FUNCTION...: SetComboAlarm()
  879. //                                                  
  880. // DESCRIPTION: set text in alarm combo box
  881. //
  882. //////////////////////////////////////////////////////////////////////////////
  883. void CPage3::SetComboAlarm(CString str) 
  884. {
  885.     if(((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck())
  886.         return;
  887.  
  888.     m_pWizSheet->m_alarm_time = atoi(str);
  889.  
  890.     AfxFormatString1(m_pWizSheet->m_text5, S37, str);
  891.     SetDlgItemText(IDC_STATIC_5, m_pWizSheet->m_text5);
  892. }
  893.  
  894. //////////////////////////////////////////////////////////////////////////////
  895. //                        
  896. // FUNCTION...: OnSelchangeComboPriority() 
  897. //                                                  
  898. // DESCRIPTION: selection was changed in priority combo box
  899. //
  900. //////////////////////////////////////////////////////////////////////////////
  901. void CPage3::OnSelchangeComboPriority() 
  902. {
  903.     int sel = ((CComboBox*)GetDlgItem(IDC_COMBO_PRIORITY))->GetCurSel();
  904.     switch(sel)
  905.     {
  906.         case 0: m_pWizSheet->m_priority = ""; break;
  907.         case 1: m_pWizSheet->m_priority = "A"; break;
  908.         case 2: m_pWizSheet->m_priority = "B"; break;
  909.         case 3: m_pWizSheet->m_priority = "C"; break;
  910.     }
  911.     if(sel)
  912.         AfxFormatString1(m_pWizSheet->m_text6, S38, m_pWizSheet->m_priority);
  913.     else
  914.         m_pWizSheet->m_text6.LoadString(S312);
  915.  
  916.     SetDlgItemText(IDC_STATIC_6, m_pWizSheet->m_text6);
  917. }
  918.  
  919. //////////////////////////////////////////////////////////////////////////////
  920. //                        
  921. // FUNCTION...: OnSetActive()
  922. //                                                  
  923. // DESCRIPTION: MFC - page is getting active
  924. //
  925. //////////////////////////////////////////////////////////////////////////////
  926. BOOL CPage3::OnSetActive() 
  927. {
  928.     GetDlgItem(IDC_STATIC_1)->SetWindowText(m_pWizSheet->m_text1);
  929.     GetDlgItem(IDC_STATIC_2)->SetWindowText(m_pWizSheet->m_text2);
  930.     GetDlgItem(IDC_STATIC_3)->SetWindowText(m_pWizSheet->m_text3);
  931.     GetDlgItem(IDC_STATIC_4)->SetWindowText(m_pWizSheet->m_text4);
  932.     GetDlgItem(IDC_STATIC_5)->SetWindowText(m_pWizSheet->m_text5);
  933.     GetDlgItem(IDC_STATIC_6)->SetWindowText(m_pWizSheet->m_text6);
  934.  
  935.     return CWizPropertyPage::OnSetActive();
  936. }
  937.  
  938. //////////////////////////////////////////////////////////////////////////////
  939. //                        
  940. // FUNCTION...: OnUpdateEditActivity()
  941. //                                                  
  942. // DESCRIPTION: check if activity text exceed length limit
  943. //
  944. //////////////////////////////////////////////////////////////////////////////
  945. void CPage3::OnUpdateEditActivity() 
  946. {
  947.     CString str;
  948.     GetDlgItem(IDC_EDIT_ACTIVITY)->GetWindowText(str);
  949.  
  950.     int len = str.GetLength();
  951.     if(len > 100)
  952.     {
  953.         AfxMessageBox(S3112);
  954.         str.SetAt(100, '\0');
  955.         GetDlgItem(IDC_EDIT_ACTIVITY)->SetFocus();
  956.         GetDlgItem(IDC_EDIT_ACTIVITY)->SetWindowText(str);
  957.     }
  958. }
  959.  
  960. //////////////////////////////////////////////////////////////////////////////
  961. //                        
  962. // FUNCTION...: OnKillActive()
  963. //                                                  
  964. // DESCRIPTION: MFC - page is losing active state
  965. //
  966. //////////////////////////////////////////////////////////////////////////////
  967. BOOL CPage3::OnKillActive() 
  968. {
  969.     //set text to text of activity type
  970.     m_pWizSheet->m_text = GetActivity(m_combo.GetCurSel());
  971.     
  972.     //get user text
  973.     CString str;
  974.     GetDlgItem(IDC_EDIT_ACTIVITY)->GetWindowText(str);
  975.  
  976.     int pos;
  977.     //remove all ',' from description 
  978.     //(',' not allowed, cause is used as delimiter char)
  979.     while((pos = str.Find(',')) > 0)
  980.     {
  981.         str.SetAt(pos, ' ');
  982.     }
  983.  
  984.     //add user entered text to description
  985.     if(!m_pWizSheet->m_text.IsEmpty() && !str.IsEmpty())
  986.         m_pWizSheet->m_text += " - ";
  987.     m_pWizSheet->m_text += str;
  988.     
  989.     return CWizPropertyPage::OnKillActive();
  990. }
  991.  
  992. //////////////////////////////////////////////////////////////////////////////
  993. //                        
  994. // FUNCTION...: OnWizardNext()
  995. //                                                  
  996. // DESCRIPTION: MFC 
  997. //
  998. //////////////////////////////////////////////////////////////////////////////
  999. LRESULT CPage3::OnWizardNext() 
  1000. {
  1001.     //warn if negative alarm time 
  1002.     if(m_pWizSheet->m_alarm_time < 0)
  1003.     {
  1004.         CString sMsg;
  1005.         sMsg.LoadString(S341);
  1006.         AfxMessageBox(sMsg);
  1007.         return -1;
  1008.     }
  1009.     
  1010.     return IDD_PAGE4;
  1011. }
  1012.  
  1013. /////////////////////////////////////////////////////////////////////////////
  1014. // CPage4 property page
  1015.  
  1016. IMPLEMENT_DYNCREATE(CPage4, CWizPropertyPage)
  1017.  
  1018. //////////////////////////////////////////////////////////////////////////////
  1019. //                        
  1020. // FUNCTION...: CPage4()
  1021. //                                                  
  1022. // DESCRIPTION: constructor
  1023. //
  1024. //////////////////////////////////////////////////////////////////////////////
  1025. CPage4::CPage4() : CWizPropertyPage(CPage4::IDD)
  1026. {
  1027. }
  1028. //////////////////////////////////////////////////////////////////////////////
  1029. //                        
  1030. // FUNCTION...: CPage4()
  1031. //                                                  
  1032. // DESCRIPTION: constructor
  1033. //
  1034. //////////////////////////////////////////////////////////////////////////////
  1035. CPage4::CPage4(CWizPropertySheet* pWizSheet) 
  1036. : CWizPropertyPage(pWizSheet, CPage4::IDD)
  1037. {
  1038.     //pointer to CWizPropertySheet
  1039.     m_pWizSheet = pWizSheet;
  1040. }
  1041.  
  1042. //////////////////////////////////////////////////////////////////////////////
  1043. //                        
  1044. // FUNCTION...: ~CPage4()
  1045. //                                                  
  1046. // DESCRIPTION: destructor
  1047. //
  1048. //////////////////////////////////////////////////////////////////////////////
  1049. CPage4::~CPage4()
  1050. {
  1051. }
  1052.  
  1053. //////////////////////////////////////////////////////////////////////////////
  1054. //                        
  1055. // FUNCTION...: DoDataExchange()
  1056. //                                                  
  1057. // DESCRIPTION: MFC
  1058. //
  1059. //////////////////////////////////////////////////////////////////////////////
  1060. void CPage4::DoDataExchange(CDataExchange* pDX)
  1061. {
  1062.     CWizPropertyPage::DoDataExchange(pDX);
  1063.     //{{AFX_DATA_MAP(CPage4)
  1064.         // NOTE: the ClassWizard will add DDX and DDV calls here
  1065.     //}}AFX_DATA_MAP
  1066. }
  1067.  
  1068.  
  1069. BEGIN_MESSAGE_MAP(CPage4, CWizPropertyPage)
  1070.     //{{AFX_MSG_MAP(CPage4)
  1071.     //}}AFX_MSG_MAP
  1072. END_MESSAGE_MAP()
  1073.  
  1074. /////////////////////////////////////
  1075. // CPage4 message handlers
  1076.  
  1077. //////////////////////////////////////////////////////////////////////////////
  1078. //                        
  1079. // FUNCTION...: OnSetActive()
  1080. //                                                  
  1081. // DESCRIPTION: MFC - page is getting active
  1082. //
  1083. //////////////////////////////////////////////////////////////////////////////
  1084. BOOL CPage4::OnSetActive() 
  1085. {
  1086.     m_pWizSheet->SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH);
  1087.  
  1088.     //update summary text
  1089.     GetDlgItem(IDC_STATIC_1)->SetWindowText(m_pWizSheet->m_text1);
  1090.     GetDlgItem(IDC_STATIC_2)->SetWindowText(m_pWizSheet->m_text2);
  1091.     GetDlgItem(IDC_STATIC_3)->SetWindowText(m_pWizSheet->m_text3);
  1092.     GetDlgItem(IDC_STATIC_4)->SetWindowText(m_pWizSheet->m_text4);
  1093.     GetDlgItem(IDC_STATIC_5)->SetWindowText(m_pWizSheet->m_text5);
  1094.     GetDlgItem(IDC_STATIC_6)->SetWindowText(m_pWizSheet->m_text6);
  1095.     
  1096.     return CWizPropertyPage::OnSetActive();
  1097. }
  1098.  
  1099. //////////////////////////////////////////////////////////////////////////////
  1100. //                        
  1101. // FUNCTION...: OnWizardBack()
  1102. //                                                  
  1103. // DESCRIPTION: MFC - back button is pressed
  1104. //
  1105. //////////////////////////////////////////////////////////////////////////////
  1106. LRESULT CPage4::OnWizardBack() 
  1107. {
  1108.     m_pWizSheet->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  1109.     
  1110.     return CWizPropertyPage::OnWizardBack();
  1111. }
  1112.  
  1113. //////////////////////////////////////////////////////////////////////////////
  1114. //                        
  1115. // FUNCTION...: OnInitDialog()
  1116. //                                                  
  1117. // DESCRIPTION: MFC
  1118. //
  1119. //////////////////////////////////////////////////////////////////////////////
  1120. BOOL CPage4::OnInitDialog() 
  1121. {
  1122.     CWizPropertyPage::OnInitDialog();
  1123.     
  1124.     return TRUE;  // return TRUE unless you set the focus to a control
  1125.                   // EXCEPTION: OCX Property Pages should return FALSE
  1126. }
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.