summaryrefslogtreecommitdiff
path: root/Checklist/NightSecWizard.cpp
diff options
context:
space:
mode:
authorStef Walter <stef@thewalter.net>2003-09-17 19:07:23 +0000
committerStef Walter <stef@thewalter.net>2003-09-17 19:07:23 +0000
commit3f95d417d9e623ac0c74df8ef11d7a01846392dd (patch)
tree45ec73f2dc07eafd7f41a6f62a8cdfbaa279469f /Checklist/NightSecWizard.cpp
Initial ImportHEADmaster
Diffstat (limited to 'Checklist/NightSecWizard.cpp')
-rw-r--r--Checklist/NightSecWizard.cpp291
1 files changed, 291 insertions, 0 deletions
diff --git a/Checklist/NightSecWizard.cpp b/Checklist/NightSecWizard.cpp
new file mode 100644
index 0000000..d394d07
--- /dev/null
+++ b/Checklist/NightSecWizard.cpp
@@ -0,0 +1,291 @@
+// NightSecWizard.cpp: implementation of the CNightSecWizard class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "stdafx.h"
+#include "NightSecWizard.h"
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+CNightSecWizard::~CNightSecWizard()
+{
+ PropertyPageMap::iterator iter = m_mapPages.begin();
+
+ for( ; iter != m_mapPages.end(); iter++)
+ delete iter->second;
+
+ m_mapPages.clear();
+};
+
+HRESULT CNightSecWizard::LoadPropertyPages(CComponentHolder* pComponent)
+{
+ IUnknown* pUnk = pComponent->GetUnknown();
+
+ IUnknown* apUnks[2];
+ apUnks[0] = pUnk;
+ apUnks[1] = pComponent->GetData()->GetUnknown();
+
+ // Don't use smart pointer here because we'll probably
+ // copy this to our map
+ IPropertyPage* pPage;
+ HRESULT hr = pUnk->QueryInterface(IID_IPropertyPage, (void**)&pPage);
+
+ // Found a single property page
+ if(SUCCEEDED(hr))
+ {
+ // Add to map and return
+ hr = pPage->SetObjects(countof(apUnks), apUnks);
+
+ if(SUCCEEDED(hr))
+ {
+ CPropPageHolder* pPropPage = new CComObjectMember<CPropPageHolder>;
+ hr = pPropPage->Initialize(pPage, GetUnknown());
+
+ if(SUCCEEDED(hr))
+ m_mapPages.insert(make_pair(pComponent, pPropPage));
+ else
+ delete pPropPage;
+ }
+
+ pPage->Release();
+ return hr;
+ }
+
+ // Look for multiple property pages
+ ISpecifyPropertyPagesPtr pPages = pUnk;
+
+ if(pPages)
+ {
+ CAUUID cauuid;
+ memset(&cauuid, 0, sizeof(CAUUID));
+
+ hr = pPages->GetPages(&cauuid);
+
+ if(FAILED(hr))
+ return hr;
+
+ HRESULT hRet = S_FALSE;
+
+ for(int nCnt = 0; nCnt < cauuid.cElems; nCnt++)
+ {
+ IPropertyPagePtr pPage;
+ hr = pPage.CreateInstance(cauuid.pElems[nCnt], NULL);
+
+ if(FAILED(hr))
+ continue;
+
+ hr = pPage->SetObjects(countof(apUnks), apUnks);
+
+ if(SUCCEEDED(hr))
+ {
+ CPropPageHolder* pPropPage = new CComObjectMember<CPropPageHolder>;
+ hr = pPropPage->Initialize(pPage, GetUnknown());
+
+ if(SUCCEEDED(hr))
+ {
+ m_mapPages.insert(make_pair(pComponent, pPropPage));
+ hRet = S_OK;
+ }
+ }
+
+ }
+
+ CoTaskMemFree(cauuid.pElems);
+
+ return hRet;
+ }
+
+ return S_FALSE;
+}
+
+IUnknown* CNightSecWizard::GetIUnknown(bool bAddRef /*= false*/)
+{
+ // If asked not to increment then Release
+ if(bAddRef)
+ this->AddRef();
+
+ return GetUnknown();
+}
+
+void CNightSecWizard::SetSite(IUnknown* pSite /*= NULL*/)
+{
+ if(!pSite)
+ pSite = GetUnknown();
+
+ IUnknown* pUnk = NULL;
+ IObjectWithSitePtr pWithSite;
+
+ // Cycle through components and set Site Pointer
+ for(int nCnt = 0; nCnt < g_aComponents.size(); nCnt++)
+ {
+ if(pUnk = g_aComponents[nCnt]->GetUnknown())
+ {
+ pWithSite = pUnk;
+
+ if(pWithSite != NULL)
+ pWithSite->SetSite(pSite);
+
+ pUnk->Release();
+ }
+ }
+}
+
+void CNightSecWizard::ClearSite()
+{
+ IUnknown* pUnk = NULL;
+ IObjectWithSitePtr pWithSite;
+
+ // Cycle through Components and Clear Site Pointer
+ for(int nCnt = 0; nCnt < g_aComponents.size(); nCnt++)
+ {
+ if(pUnk = g_aComponents[nCnt]->GetUnknown())
+ {
+ pWithSite = pUnk;
+
+ if(pWithSite != NULL)
+ pWithSite->SetSite(NULL);
+
+ pUnk->Release();
+ }
+ }
+}
+
+LRESULT CNightSecWizard::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ // Make sure that that CPropertySheet::OnInitDialog gets called
+ bHandled = FALSE;
+
+ ModifyStyle(0, WS_SYSMENU);
+ ModifyStyleEx(0, WS_EX_APPWINDOW | WS_EX_CONTEXTHELP);
+ SetWindowText(_T("Night Security Checklist"));
+
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////
+// CAdvancedWizard
+
+LRESULT CAdvancedWizardT::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ // Make sure that that CPropertySheet::OnInitDialog gets called
+ bHandled = FALSE;
+
+ SetSite();
+
+ // Cycle through components and...
+ for(int nCnt = 0; nCnt < g_aComponents.size(); nCnt++)
+ {
+ // And Load Property Pages for that Component
+ LoadPropertyPages(g_aComponents[nCnt]);
+ }
+
+ return 0;
+}
+
+LRESULT CAdvancedWizardT::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ ClearSite();
+
+ // And Destroy all Property Pages
+ PropertyPageMap::iterator iter = m_mapPages.begin();
+ for( ; iter != m_mapPages.end(); iter++)
+ iter->second->Destroy();
+
+ return 0;
+}
+
+STDMETHODIMP CAdvancedWizardT::get_Info(/*[in]*/ NightSecSiteInfo nsItem, /*[out, retval]*/ VARIANT* pvVal)
+{
+ ::VariantClear(pvVal);
+
+ // CComBSTR bsRetVal;
+ switch(nsItem)
+ {
+ case nsAdvanced:
+ pvVal->vt = VT_BOOL;
+ pvVal->bVal = TRUE;
+ return S_OK;
+ }
+
+ return S_FALSE;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// CNormalWizard
+
+CNormalWizardT::~CNormalWizardT()
+{
+ ExtraPageArray::iterator iter = m_aPages.begin();
+ for( ; iter != m_aPages.end(); iter++)
+ delete *iter;
+
+ m_aPages.clear();
+}
+
+STDMETHODIMP CNormalWizardT::get_Info(/*[in]*/ NightSecSiteInfo nsItem, /*[out, retval]*/ VARIANT* pvVal)
+{
+ ::VariantClear(pvVal);
+
+ // CComBSTR bsRetVal;
+ switch(nsItem)
+ {
+ case nsAdvanced:
+ pvVal->vt = VT_BOOL;
+ pvVal->bVal = FALSE;
+ return S_OK;
+ }
+
+ return S_FALSE;
+}
+
+LRESULT CNormalWizardT::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ // Make sure that that CPropertySheet::OnInitDialog gets called
+ bHandled = FALSE;
+
+ if(!m_bSiteSet)
+ {
+ SetSite();
+ m_bSiteSet = true;
+ }
+
+ return 0;
+};
+
+LRESULT CNormalWizardT::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ ClearSite();
+
+ PropertyPageMap::iterator iter = m_mapPages.begin();
+ for( ; iter != m_mapPages.end(); iter++)
+ iter->second->Destroy();
+
+ return 0;
+};
+
+void CNormalWizardT::AddExtraPages()
+{
+ if(!m_bSiteSet)
+ {
+ SetSite();
+ m_bSiteSet = true;
+ }
+
+ for(int nCnt = 0; nCnt < g_aComponents.size(); nCnt++)
+ {
+ if(g_aComponents[nCnt]->GetInfoInt(nsForceShow, 0))
+ LoadPropertyPages(g_aComponents[nCnt]);
+ }
+
+ PropertyPageMap::iterator iter = m_mapPages.begin();
+ for( ; iter != m_mapPages.end(); iter++)
+ {
+ CExtraPage* pPage = new CExtraPage(this, iter->first, iter->second);
+ AddPage(pPage);
+ m_aPages.insert(m_aPages.end(), pPage);
+ }
+}