summaryrefslogtreecommitdiff
path: root/Checklist/NormalPage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Checklist/NormalPage.cpp')
-rw-r--r--Checklist/NormalPage.cpp189
1 files changed, 189 insertions, 0 deletions
diff --git a/Checklist/NormalPage.cpp b/Checklist/NormalPage.cpp
new file mode 100644
index 0000000..de35ff2
--- /dev/null
+++ b/Checklist/NormalPage.cpp
@@ -0,0 +1,189 @@
+// NormalPage.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "NormalPage.h"
+#include "ExtraPage.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// CNormalPage property page
+
+
+CNormalPage::CNormalPage(CPropertySheet* pParent, UINT nPos)
+ : CPropertyPage(IDD),
+ m_nPos(nPos)
+{
+ ASSERT(pParent); // Have to have a valid parent
+ m_pParentSheet = pParent; // or we can't survive
+ SetHelp(true);
+}
+
+CNormalPage::~CNormalPage()
+{
+ m_pParentSheet = NULL;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// CNormalPage message handlers
+
+LRESULT CNormalPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ m_ctlCheck.SubclassWindow(GetDlgItem(IDC_COMPONENTS));
+
+ int nIndex = 0;
+
+ // Loop through and Add Components to Box
+ for(int nCnt = 0; nCnt < g_aComponents.size(); nCnt++)
+ {
+ // Only show if enabled or Not a component that Hides in Normal Mode
+ if(!g_aComponents[nCnt]->GetInfoInt(nsHideNormal, FALSE) || g_aComponents[nCnt]->IsEnabled())
+ {
+ // Add the Title
+ nIndex = m_ctlCheck.AddString(g_aComponents[nCnt]->GetName());
+
+ // Save a Pointer to the component in the Listbox Data
+ m_ctlCheck.SetItemDataPtr(nIndex, (void*)g_aComponents[nCnt]);
+
+ // Check if Enabled
+ m_ctlCheck.SetCheck(nIndex, g_aComponents[nCnt]->IsEnabled());
+ }
+
+ }
+
+ // Select first item and display help text
+ m_ctlCheck.SetCurSel(0);
+ SetTips();
+
+ // Set the Help ID for our Help File
+// m_nIDHelp = 1;
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+//////////////////////////////////////////////////////////////////
+// When the Finish Button on Wizard is pressed
+
+LRESULT CNormalPage::OnWizBack(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
+{
+ // Save Pos and Enabled Status
+ SaveChanges();
+ return 0;
+}
+
+//////////////////////////////////////////////////////////////////
+// Have to save our changes when focus changes cause
+// OnWizardFinish doesn't get called for each sheet
+
+LRESULT CNormalPage::OnWizFinish(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
+{
+ SaveChanges();
+ return 0;
+}
+
+//////////////////////////////////////////////////////////////////
+// Have to save our changes when focus changes cause
+// OnWizardFinish doesn't get called for each sheet
+
+LRESULT CNormalPage::OnWizNext(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
+{
+ SaveChanges();
+ return 0;
+}
+
+LRESULT CNormalPage::OnHelp(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
+{
+ WinHelp(NS_HELP_FILE, HELP_FINDER, 0);
+ return 1;
+}
+
+//////////////////////////////////////////////////////////////////
+// Make sure our buttons are properly enabled based on our
+// position (passed in constructor)
+
+LRESULT CNormalPage::OnSetActive(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
+{
+ DWORD dwButtons;
+
+ // Depening on our Position in the Wizard
+ // Set the Buttons at the bottom on and off
+
+ switch(m_nPos)
+ {
+ case WIZPAGE_FIRST:
+ dwButtons = PSWIZB_NEXT;
+ break;
+ case WIZPAGE_LAST:
+ dwButtons = PSWIZB_BACK | PSWIZB_FINISH;
+ break;
+ default:
+ dwButtons = PSWIZB_BACK | PSWIZB_NEXT;
+ break;
+ }
+
+ m_pParentSheet->SetWizardButtons(dwButtons);
+
+ return 0;
+}
+
+
+//////////////////////////////////////////////////////////////////
+// Basically saves Position of component and Enabled Status
+
+HRESULT CNormalPage::SaveChanges()
+{
+ HRESULT hrRet = S_OK;
+ CComponentHolder* pComponent;
+
+ // Loop though and save Pos and Enabled Status
+ for(int nCnt = 0; nCnt < m_ctlCheck.GetCount(); nCnt++) {
+
+ // Get the Pointer from Listbox Data
+ pComponent = (CComponentHolder*)m_ctlCheck.GetItemDataPtr(nCnt);
+
+ if(pComponent)
+ {
+ // Save to Component Data
+ pComponent->Enable(m_ctlCheck.GetCheck(nCnt) ? true : false);
+// pComponent->SetPos((nCnt * 2) + m_nType - 1); // Need special calculations because we have a number of type sharing same position list
+
+ }
+ else
+
+ // Bummed out and don't know why
+ hrRet = E_UNEXPECTED;
+
+ }
+
+ return hrRet;
+
+}
+
+//////////////////////////////////////////////////////////////////
+// Change Help text for each new component
+
+LRESULT CNormalPage::OnComponentsSelChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ SetTips();
+ return 1;
+}
+
+//////////////////////////////////////////////////////////////////
+// Display Help Text
+
+void CNormalPage::SetTips()
+{
+
+ // Get current selection
+ int nCurSel = m_ctlCheck.GetCurSel();
+
+ if(nCurSel == LB_ERR)
+ return;
+
+ // Get current selection
+ CComponentHolder* pComponent = (CComponentHolder*)m_ctlCheck.GetItemDataPtr(nCurSel);
+
+ if(pComponent)
+ SetDlgItemText(IDC_TIPS, pComponent->GetInfoStr(nsHelpText, _T("(No help available)")));
+}
+