Click here to Skip to main content
15,897,518 members
Articles / Desktop Programming / MFC

Exile 1.8 - The Password Manager

Rate me:
Please Sign up or sign in to vote.
4.57/5 (51 votes)
6 Mar 20058 min read 257.6K   7.4K   111  
Yet another password manager.
// OptionsDialog.cpp : implementation file
//

#include "stdafx.h"
#include "exile.h"
#include "OptionsDialog.h"
#include "Registry.h"
#include "messagebox.h"
#include "ValueParser.h"
#include "modulepath.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#import <msxml3.dll>

using namespace MSXML2;

/////////////////////////////////////////////////////////////////////////////
// COptionsDialog dialog


COptionsDialog::COptionsDialog(CWnd* pParent /*=NULL*/)
	: CDialog(COptionsDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(COptionsDialog)
	m_bMinimizeToTray = FALSE;
	m_bReloadLastStorage = FALSE;
	m_bAutosave = FALSE;
	m_bAutosort = FALSE;
	m_bSmartType = FALSE;
	m_bBackup = FALSE;
	m_bMaintainFileAssociations = FALSE;
	//}}AFX_DATA_INIT
}


void COptionsDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COptionsDialog)
/*	DDX_Control(pDX, IDC_HOTKEY, m_ctrlHotKey);
	DDX_Control(pDX, IDC_SORTORDER, m_ctrlSortOrder);
	DDX_Check(pDX, IDC_MINIMIZETOTRAY, m_bMinimizeToTray);
	DDX_Check(pDX, IDC_RELOADSTORAGE, m_bReloadLastStorage);
	DDX_Check(pDX, IDC_AUTOSAVE, m_bAutosave);
	DDX_Check(pDX, IDC_AUTOSORT, m_bAutosort);
	DDX_Check(pDX, IDC_SMARTTYPE, m_bSmartType);
	DDX_Check(pDX, IDC_BACKUP, m_bBackup);
	DDX_Check(pDX, IDC_MAINTAINASSOCIATIONS, m_bMaintainFileAssociations);*/
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COptionsDialog, CDialog)
	//{{AFX_MSG_MAP(COptionsDialog)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COptionsDialog message handlers

BOOL COptionsDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();

	//
	// Initializing Property Browser
	//
	m_ctrlBrowser.Create(MAKEINTRESOURCE(IDD_PROPERTYBROWSER_DIALOG), this);

	CRect rc;
	GetDlgItem(IDC_PROPERTIES)->GetClientRect(rc);
	GetDlgItem(IDC_PROPERTIES)->MapWindowPoints(this, rc);

	m_ctrlBrowser.MoveWindow(rc);
	m_ctrlBrowser.PostCreate();
	m_ctrlBrowser.LayoutBrowser(0.75);
	m_ctrlBrowser.ShowWindow(SW_SHOW);

	//
	// Loading Property Grid contents
	//

	IXMLDOMDocument2Ptr pXML;

	if(FAILED(pXML.CreateInstance(__uuidof(DOMDocument30))))
	{
		return FALSE;
	} // if

	if(VARIANT_FALSE == pXML->load(_variant_t(CombinePathName(_T("options.xml")))))
	{
		return FALSE;
	} // if

		
	m_ctrlBrowser.GetPropertyGrid().LoadPropertyGridContents(pXML->documentElement);

	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(1, m_bMaintainFileAssociations ? _T("Yes") : _T("No")));
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(3, m_bMinimizeToTray ? _T("Yes") : _T("No")));
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(4, m_bBackup ? _T("Yes") : _T("No")));
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(5, m_bAutosave ? _T("Yes") : _T("No")));
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(15, m_bShellOpenReadOnly ? _T("Yes") : _T("No")));	
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(6, m_bReloadLastStorage ? _T("Yes") : _T("No")));
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(7, m_strStorageName));
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(8, m_bSmartType ? _T("Yes") : _T("No")));
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetHotKey(9, MAKEWORD(m_wKeyCode, m_wModifiers)));
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(10, m_bAutosort ? _T("Yes") : _T("No")));	
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetComboBoxValue(11, m_nSort));
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(12, m_bReloadReadonly ? _T("Yes") : _T("No")));	
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(12, m_bReloadReadonly ? _T("Yes") : _T("No")));
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetElementValue(13, m_bClipboardErasing ? _T("Yes") : _T("No")));
	VERIFY(m_ctrlBrowser.GetPropertyGrid().SetEditBoxLong(14, m_nErasingTimeout));

	if(VARIANT_FALSE == pXML->load(_variant_t(CombinePathName(_T("theme.xml")))))
	{
		return FALSE;
	} // if

	//
	// Loading Property Grid theme
	//

	m_ctrlBrowser.GetPropertyGrid().LoadPropertyGridTheme(pXML->documentElement);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void COptionsDialog::OnOK() 
{
	m_ctrlBrowser.GetPropertyGrid().AcceptEdit();

	m_nSort = m_ctrlBrowser.GetPropertyGrid().GetComboBoxItemData(11);
	m_bMaintainFileAssociations = CValueParser::ParseYesNoToBool(m_ctrlBrowser.GetPropertyGrid().GetElementValue(1));
	m_bMinimizeToTray = CValueParser::ParseYesNoToBool(m_ctrlBrowser.GetPropertyGrid().GetElementValue(3));
	m_bBackup = CValueParser::ParseYesNoToBool(m_ctrlBrowser.GetPropertyGrid().GetElementValue(4));
	m_bAutosave = CValueParser::ParseYesNoToBool(m_ctrlBrowser.GetPropertyGrid().GetElementValue(5));
	m_bReloadLastStorage = CValueParser::ParseYesNoToBool(m_ctrlBrowser.GetPropertyGrid().GetElementValue(6));
	m_bSmartType = CValueParser::ParseYesNoToBool(m_ctrlBrowser.GetPropertyGrid().GetElementValue(8));
	m_bAutosort = CValueParser::ParseYesNoToBool(m_ctrlBrowser.GetPropertyGrid().GetElementValue(10));
	m_bReloadReadonly = CValueParser::ParseYesNoToBool(m_ctrlBrowser.GetPropertyGrid().GetElementValue(12));
	m_bShellOpenReadOnly = CValueParser::ParseYesNoToBool(m_ctrlBrowser.GetPropertyGrid().GetElementValue(15));
	m_bClipboardErasing = CValueParser::ParseYesNoToBool(m_ctrlBrowser.GetPropertyGrid().GetElementValue(13));
	m_nErasingTimeout = m_ctrlBrowser.GetPropertyGrid().GetEditBoxLong(14);

	// Hot key
	m_wKeyCode = LOBYTE(m_ctrlBrowser.GetPropertyGrid().GetHotKey(9));
	m_wModifiers = HIBYTE(m_ctrlBrowser.GetPropertyGrid().GetHotKey(9));

	CDialog::OnOK();
}

void COptionsDialog::SetSettings(CSettings *pstSettings)
{

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Russian Federation Russian Federation
I'll think about it later on...

Comments and Discussions