home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / mailx6 / _setup.2 / Group7 / PPage1.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-06  |  10.8 KB  |  413 lines

  1. // MyPropertyPage1.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "resource.h"
  6. #include "PPage1.h"
  7. #include "Wiz95Dlg.h"
  8. #include "Wizard95.h"
  9. #include "PSheet.h"
  10.  
  11.  
  12. #ifdef _DEBUG
  13. #undef THIS_FILE
  14. static char BASED_CODE THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. IMPLEMENT_DYNCREATE(CMyPropertyPage1, CPropertyPage)
  18. IMPLEMENT_DYNCREATE(CMyPropertyPage2, CPropertyPage)
  19. IMPLEMENT_DYNCREATE(CMyPropertyPage3, CPropertyPage)
  20. IMPLEMENT_DYNCREATE(CMyPropertyPage4, CPropertyPage)
  21. IMPLEMENT_DYNCREATE(CMyPropertyPage5, CPropertyPage)
  22.  
  23.  
  24. extern CWizard95App theApp;
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CMyPropertyPage1 property page
  27.  
  28. CMyPropertyPage1::CMyPropertyPage1() : CPropertyPage(CMyPropertyPage1::IDD)
  29. {
  30.     //{{AFX_DATA_INIT(CMyPropertyPage1)
  31.     m_MailSystem = -1;
  32.     //}}AFX_DATA_INIT
  33. }
  34.  
  35. CMyPropertyPage1::~CMyPropertyPage1()
  36. {
  37. }
  38.  
  39. void CMyPropertyPage1::DoDataExchange(CDataExchange* pDX)
  40. {
  41.     CPropertyPage::DoDataExchange(pDX);
  42.     //{{AFX_DATA_MAP(CMyPropertyPage1)
  43.     DDX_Radio(pDX, IDC_CCMAIL, m_MailSystem);
  44.     //}}AFX_DATA_MAP
  45. }
  46.  
  47.  
  48. BEGIN_MESSAGE_MAP(CMyPropertyPage1, CPropertyPage)
  49.     //{{AFX_MSG_MAP(CMyPropertyPage1)
  50.     //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52.  
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CMyPropertyPage2 property page
  56.  
  57. CMyPropertyPage2::CMyPropertyPage2() : CPropertyPage(CMyPropertyPage2::IDD)
  58. {
  59.     //{{AFX_DATA_INIT(CMyPropertyPage2)
  60.     m_Name = _T("");
  61.     m_Password = _T("");
  62.     //}}AFX_DATA_INIT
  63. }
  64.  
  65. CMyPropertyPage2::~CMyPropertyPage2()
  66. {
  67. }
  68.  
  69. void CMyPropertyPage2::DoDataExchange(CDataExchange* pDX)
  70. {
  71.     CPropertyPage::DoDataExchange(pDX);
  72.     //{{AFX_DATA_MAP(CMyPropertyPage2)
  73.     DDX_Text(pDX, IDC_NAME, m_Name);
  74.     DDX_Text(pDX, IDC_PASSWORD, m_Password);
  75.     //}}AFX_DATA_MAP
  76. }
  77.  
  78.  
  79. BEGIN_MESSAGE_MAP(CMyPropertyPage2, CPropertyPage)
  80.     //{{AFX_MSG_MAP(CMyPropertyPage2)
  81.         // NOTE: the ClassWizard will add message map macros here
  82.     //}}AFX_MSG_MAP
  83. END_MESSAGE_MAP()
  84.  
  85.  
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CMyPropertyPage3 property page
  88.  
  89. CMyPropertyPage3::CMyPropertyPage3() : CPropertyPage(CMyPropertyPage3::IDD)
  90. {
  91.     //{{AFX_DATA_INIT(CMyPropertyPage3)
  92.     m_TotalNum = _T("");
  93.     //}}AFX_DATA_INIT
  94.     m_InboxMsg=FALSE;
  95. }
  96.  
  97. CMyPropertyPage3::~CMyPropertyPage3()
  98. {
  99. }
  100.  
  101. void CMyPropertyPage3::DoDataExchange(CDataExchange* pDX)
  102. {
  103.     CPropertyPage::DoDataExchange(pDX);
  104.     //{{AFX_DATA_MAP(CMyPropertyPage3)
  105.     DDX_Control(pDX, IDC_LIST1, m_List);
  106.     DDX_Text(pDX, IDC_NUM, m_TotalNum);
  107.     DDV_MaxChars(pDX, m_TotalNum, 5);
  108.     //}}AFX_DATA_MAP
  109. }
  110.  
  111.  
  112. BEGIN_MESSAGE_MAP(CMyPropertyPage3, CPropertyPage)
  113.     //{{AFX_MSG_MAP(CMyPropertyPage3)
  114.     ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  115.     //}}AFX_MSG_MAP
  116. END_MESSAGE_MAP()
  117.  
  118.  
  119. /////////////////////////////////////////////////////////////////////////////
  120. // CMyPropertyPage4 property page
  121.  
  122. CMyPropertyPage4::CMyPropertyPage4() : CPropertyPage(CMyPropertyPage4::IDD)
  123. {
  124.     //{{AFX_DATA_INIT(CMyPropertyPage4)
  125.     m_szNotePart = _T("");
  126.     m_szSubject = _T("");
  127.     m_szFrom = _T("");
  128.     //}}AFX_DATA_INIT
  129. }
  130.  
  131. CMyPropertyPage4::~CMyPropertyPage4()
  132. {
  133. }
  134.  
  135. void CMyPropertyPage4::DoDataExchange(CDataExchange* pDX)
  136. {
  137.     CPropertyPage::DoDataExchange(pDX);
  138.     //{{AFX_DATA_MAP(CMyPropertyPage4)
  139.     DDX_Control(pDX, IDC_REPLY, m_Reply);
  140.     DDX_Control(pDX, IDC_FORWARD, m_Forward);
  141.     DDX_Text(pDX, IDC_NOTEPART, m_szNotePart);
  142.     DDX_Text(pDX, IDC_SUBJECT, m_szSubject);
  143.     DDX_Text(pDX, IDC_FROM, m_szFrom);
  144.     //}}AFX_DATA_MAP
  145. }
  146.  
  147.  
  148. BEGIN_MESSAGE_MAP(CMyPropertyPage4, CPropertyPage)
  149.     //{{AFX_MSG_MAP(CMyPropertyPage4)
  150.     ON_BN_CLICKED(IDC_SEND, OnSend)
  151.     ON_BN_CLICKED(IDC_REPLY, OnReply)
  152.     ON_BN_CLICKED(IDC_FORWARD, OnForward)
  153.     //}}AFX_MSG_MAP
  154. END_MESSAGE_MAP()
  155.  
  156.  
  157. /////////////////////////////////////////////////////////////////////////////
  158. // CMyPropertyPage5 property page
  159.  
  160. CMyPropertyPage5::CMyPropertyPage5() : CPropertyPage(CMyPropertyPage5::IDD)
  161. {
  162.     //{{AFX_DATA_INIT(CMyPropertyPage5)
  163.         // NOTE: the ClassWizard will add member initialization here
  164.     //}}AFX_DATA_INIT
  165. }
  166.  
  167. CMyPropertyPage5::~CMyPropertyPage5()
  168. {
  169. }
  170.  
  171. void CMyPropertyPage5::DoDataExchange(CDataExchange* pDX)
  172. {
  173.     CPropertyPage::DoDataExchange(pDX);
  174.     //{{AFX_DATA_MAP(CMyPropertyPage5)
  175.         // NOTE: the ClassWizard will add DDX and DDV calls here
  176.     //}}AFX_DATA_MAP
  177. }
  178.  
  179.  
  180. BEGIN_MESSAGE_MAP(CMyPropertyPage5, CPropertyPage)
  181.     //{{AFX_MSG_MAP(CMyPropertyPage5)
  182.         // NOTE: the ClassWizard will add message map macros here
  183.     //}}AFX_MSG_MAP
  184. END_MESSAGE_MAP()
  185.  
  186.  
  187.  
  188. BOOL CMyPropertyPage1::OnInitDialog() 
  189. {
  190.     CPropertyPage::OnInitDialog();
  191.     
  192.     // TODO: Add extra initialization here
  193.     m_MailSystem=0;
  194.     return TRUE;  // return TRUE unless you set the focus to a control
  195.                   // EXCEPTION: OCX Property Pages should return FALSE
  196. }
  197.  
  198. BOOL CMyPropertyPage1::OnSetActive() 
  199. {
  200.     // TODO: Add your specialized code here and/or call the base class
  201.     CPropertySheet *pSheet=(CPropertySheet *) GetParent();
  202.     pSheet->SetWizardButtons(PSWIZB_NEXT);
  203.     return CPropertyPage::OnSetActive();
  204. }
  205.  
  206. LRESULT CMyPropertyPage1::OnWizardNext() 
  207. {
  208.     // TODO: Add your specialized code here and/or call the base class
  209.     UpdateData();
  210.     switch (m_MailSystem)
  211.     {
  212.     case 0:
  213.         theApp.m_pDlg->m_Session.SetMail_Type(2);
  214.         break;
  215.     case 1:
  216.         theApp.m_pDlg->m_Session.SetMail_Type(1);
  217.         break;
  218.     case 2:
  219.         theApp.m_pDlg->m_Session.SetMail_Type(3);
  220.         break;
  221.     }
  222.  
  223.     if  (theApp.m_pDlg->m_Session.GetErrorNum()!=0) return -1;
  224.  
  225.     return CPropertyPage::OnWizardNext();
  226. }
  227.  
  228. BOOL CMyPropertyPage2::OnSetActive() 
  229. {
  230.     // TODO: Add your specialized code here and/or call the base class
  231.     CPropertySheet *pSheet=(CPropertySheet *) GetParent();
  232.     pSheet->SetWizardButtons(PSWIZB_NEXT|PSWIZB_BACK);
  233.     return CPropertyPage::OnSetActive();
  234. }
  235.  
  236. LRESULT CMyPropertyPage2::OnWizardNext() 
  237. {
  238.     // TODO: Add your specialized code here and/or call the base class
  239.     UpdateData();
  240.     theApp.m_pDlg->m_Session.SetUser(m_Name);
  241.     theApp.m_pDlg->m_Session.SetPassword(m_Password);
  242.     theApp.m_pDlg->m_Session.SetLogon(TRUE);
  243.  
  244.     if  (theApp.m_pDlg->m_Session.GetErrorNum()!=0 ||
  245.         theApp.m_pDlg->m_Session.GetLogon()!=TRUE) return -1;
  246.  
  247.     return CPropertyPage::OnWizardNext();
  248. }
  249.  
  250. LRESULT CMyPropertyPage3::OnWizardNext() 
  251. {
  252.     // TODO: Add your specialized code here and/or call the base class
  253.     return CPropertyPage::OnWizardNext();
  254. }
  255.  
  256. BOOL CMyPropertyPage3::OnSetActive() 
  257. {
  258.     // TODO: Add your specialized code here and/or call the base class
  259.     CMyPropertySheet *pSheet=(CMyPropertySheet *) GetParent();
  260.     pSheet->SetWizardButtons(PSWIZB_NEXT|PSWIZB_BACK);
  261.     /* Try TO re-scan your Inbox!!*/
  262.  
  263.     BeginWaitCursor();
  264.     m_List.SetRedraw(FALSE);
  265.     m_List.DeleteAllItems();
  266.  
  267.     theApp.m_pDlg->m_Message.SetWorkingMsg(0);
  268.     theApp.m_pDlg->m_Message.SetAction(3); //Fetch First
  269.     ULONG mCount=0;
  270.     while (theApp.m_pDlg->m_Message.GetErrorNum()==0)
  271.     {
  272.         BOOL IsUnread;
  273.         CString Subject;
  274.         long MsgNum;
  275.         mCount++;
  276.         Subject=theApp.m_pDlg->m_Message.GetSubject();
  277.         IsUnread=theApp.m_pDlg->m_Message.GetUnreadMsg();
  278.         MsgNum=theApp.m_pDlg->m_Message.GetFetchMsg();
  279.         m_List.InsertItem(    LVIF_TEXT|LVIF_PARAM,
  280.                             0,
  281.                             (const char *) Subject,
  282.                             0,
  283.                             0,
  284.                             (int) !IsUnread,
  285.                             (LPARAM) MsgNum);
  286.  
  287.         theApp.m_pDlg->m_Message.SetAction(2); //Fetch Next
  288.     }
  289.  
  290.     EndWaitCursor();
  291.     char szTemp[25];
  292.     wsprintf(szTemp,"%lu",mCount);
  293.     m_TotalNum=szTemp;
  294.     m_List.SetRedraw(TRUE);
  295.  
  296.     /* Clear Next Page Items!*/
  297.     pSheet->m_Page4.m_szSubject=_T("");
  298.     pSheet->m_Page4.m_szNotePart=_T("");
  299.     pSheet->m_Page4.m_szFrom=_T("");
  300.     m_InboxMsg=FALSE;
  301.     return CPropertyPage::OnSetActive();
  302. }
  303.  
  304. BOOL CMyPropertyPage3::OnInitDialog() 
  305. {
  306.     CPropertyPage::OnInitDialog();
  307.     
  308.     // TODO: Add extra initialization here
  309.     m_ImageList.Create(IDB_IMAGELIST,32,4,RGB(255,255,255));    
  310.     m_List.SetImageList(&m_ImageList,LVSIL_SMALL);
  311.     return TRUE;  // return TRUE unless you set the focus to a control
  312.                   // EXCEPTION: OCX Property Pages should return FALSE
  313. }
  314.  
  315. BOOL CMyPropertyPage5::OnSetActive() 
  316. {
  317.     // TODO: Add your specialized code here and/or call the base class
  318.     CPropertySheet *pSheet=(CPropertySheet *) GetParent();
  319.     pSheet->SetWizardButtons(PSWIZB_FINISH|PSWIZB_BACK);
  320.  
  321.     return CPropertyPage::OnSetActive();
  322. }
  323.  
  324. BOOL CMyPropertyPage4::OnSetActive() 
  325. {
  326.     // TODO: Add your specialized code here and/or call the base class
  327.     CMyPropertySheet *pSheet=(CMyPropertySheet *) GetParent();
  328.     pSheet->SetWizardButtons(PSWIZB_NEXT|PSWIZB_BACK);
  329.  
  330.     if (pSheet->m_Page3.m_InboxMsg)
  331.     {
  332.         pSheet->m_Page4.m_Forward.EnableWindow(TRUE);
  333.         pSheet->m_Page4.m_Reply.EnableWindow(TRUE);
  334.     }
  335.     else
  336.     {
  337.         pSheet->m_Page4.m_Forward.EnableWindow(FALSE);
  338.         pSheet->m_Page4.m_Reply.EnableWindow(FALSE);
  339.     }
  340.     
  341.     return CPropertyPage::OnSetActive();
  342. }
  343.  
  344. void CMyPropertyPage3::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) 
  345. {
  346.     // TODO: Add your control notification handler code here
  347.     CMyPropertySheet *pSheet=(CMyPropertySheet *) GetParent();
  348.  
  349.     int Index;
  350.     Index=m_List.GetNextItem(-1,LVNI_SELECTED|LVNI_FOCUSED);
  351.     if (Index>=0)
  352.     {
  353.         long MsgNum=m_List.GetItemData(Index);
  354.  
  355.         theApp.m_pDlg->m_ReadMsg.SetWorkingMsg(0);
  356.         theApp.m_pDlg->m_ReadMsg.SetFetchMsg(MsgNum);
  357.  
  358.         if (theApp.m_pDlg->m_ReadMsg.GetErrorNum()==0)
  359.         {
  360.             theApp.m_pDlg->m_Originator.SetFetchRecipient(TRUE);
  361.             pSheet->m_Page4.m_szSubject=theApp.m_pDlg->m_ReadMsg.GetSubject();
  362.             pSheet->m_Page4.m_szNotePart=theApp.m_pDlg->m_ReadMsg.GetNoteText();
  363.             pSheet->m_Page4.m_szFrom=theApp.m_pDlg->m_Originator.GetRecipientName();
  364.             m_InboxMsg=TRUE;
  365.             pSheet->PressButton(PSBTN_NEXT);
  366.         }
  367.         
  368.     }
  369.     
  370.     *pResult = 0;
  371. }
  372.  
  373. void CMyPropertyPage4::OnSend() 
  374. {
  375.     // TODO: Add your control notification handler code here
  376.     UpdateData();
  377.     theApp.m_pDlg->m_ReadMsg.SetAction(7); //New Message
  378.     theApp.m_pDlg->m_ReadMsg.SetWorkingMsg(1);
  379.     theApp.m_pDlg->m_ReadMsg.SetSubject(m_szSubject);
  380.     theApp.m_pDlg->m_ReadMsg.SetNoteText(m_szNotePart);
  381.     theApp.m_pDlg->m_ReadMsg.SetAction(13); //Send Message
  382.     if (theApp.m_pDlg->m_ReadMsg.GetErrorNum()!=0)
  383.     {
  384.         MessageBox("Unable to Send Message","Mail eXtension OCX-32 v1.60",MB_ICONSTOP);
  385.     }
  386.     
  387. }
  388.  
  389. void CMyPropertyPage4::OnReply() 
  390. {
  391.     // TODO: Add your control notification handler code here
  392.     theApp.m_pDlg->m_ReadMsg.SetAction(8); //New Message
  393.     theApp.m_pDlg->m_ReadMsg.SetWorkingMsg(0);
  394.     theApp.m_pDlg->m_ReadMsg.SetAction(13); //Send Message
  395.     if (theApp.m_pDlg->m_ReadMsg.GetErrorNum()!=0)
  396.     {
  397.         MessageBox("Unable to Send Message","Mail eXtension OCX-32 v1.60",MB_ICONSTOP);
  398.     }
  399. }
  400.  
  401. void CMyPropertyPage4::OnForward() 
  402. {
  403.     // TODO: Add your control notification handler code here
  404.     theApp.m_pDlg->m_ReadMsg.SetAction(9); //Forward Message
  405.     theApp.m_pDlg->m_ReadMsg.SetWorkingMsg(0);
  406.     theApp.m_pDlg->m_ReadMsg.SetAction(13); //Send Message
  407.     if (theApp.m_pDlg->m_ReadMsg.GetErrorNum()!=0)
  408.     {
  409.         MessageBox("Unable to Send Message","Mail eXtension OCX-32 v1.60",MB_ICONSTOP);
  410.     }
  411.     
  412. }
  413.