Click here to Skip to main content
15,896,606 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.5K   7.4K   111  
Yet another password manager.
/********************************************************************
	Created:	27/3/2004, 14:36
	File name: 	D:\Projects\Exile\Exile\GroupedControls.cpp
	File path:	D:\Projects\Exile\Exile
	File base:	GroupedControls
	File ext:	cpp
	Author:		Gogolev Anton
*********************************************************************/

// GroupedControls.cpp: implementation of the CGroupedControls class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Exile.h"
#include "GroupedControls.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CGroupedControls::CGroupedControls()
{

}

CGroupedControls::~CGroupedControls()
{

}

void CGroupedControls::AddControl(const int nGroupID, const HWND hControl)
{
	GROUPEDCONTROLITEM gci;

	gci.hWnd = hControl;
	gci.nGroupID = nGroupID;

	m_vControls.push_back(gci);
}

void CGroupedControls::RemoveControl(const HWND hControl)
{
	VGROUPEDCONTROL::iterator vgci = m_vControls.begin();

	while(m_vControls.end() != vgci) 
	{
		if(hControl == vgci->hWnd)
			vgci = m_vControls.erase(vgci);
	} // while
}

void CGroupedControls::ShowControls(const int nGroupID) const
{
	for(size_t s = 0; s < m_vControls.size(); ++s)
	{
		if(nGroupID == m_vControls[s].nGroupID)
			::ShowWindow(m_vControls[s].hWnd, SW_SHOW);
	} // for
}

void CGroupedControls::HideControls(const int nGroupID) const
{
	for(size_t s = 0; s < m_vControls.size(); ++s)
	{
		if(nGroupID == m_vControls[s].nGroupID)
			::ShowWindow(m_vControls[s].hWnd, SW_HIDE);
	} // for
}

void CGroupedControls::EnableControls(const int nGroupID) const
{
	for(size_t s = 0; s < m_vControls.size(); ++s)
	{
		if(nGroupID == m_vControls[s].nGroupID)
			::EnableWindow(m_vControls[s].hWnd, TRUE);
	} // for
}

void CGroupedControls::DisableControls(const int nGroupID) const
{
	for(size_t s = 0; s < m_vControls.size(); ++s)
	{
		if(nGroupID == m_vControls[s].nGroupID)
			::EnableWindow(m_vControls[s].hWnd, FALSE);
	} // for
}

void CGroupedControls::SwitchControls(const int nGroupID, const SWITCH_STATES nState) const
{
	switch(nState) 
	{
	case SWS_ENABLE:
		EnableControls(nGroupID);
		break;
	case SWS_DISABLE:
		DisableControls(nGroupID);
		break;
	case SWS_SHOW:
		ShowControls(nGroupID);
		break;
	case SWS_HIDE:
		HideControls(nGroupID);
		break;
	default:
		break;
	} // switch
}

void CGroupedControls::SwitchControls(const int nGroupID, const SWITCH_STATES nState, 
									  const SWITCH_STATES nOuterState) const
{
	// First, process all other groups in case some controls exist in several
	// groups.
	size_t s;

	switch(nOuterState) 
	{
	case SWS_ENABLE:
		for(s = 0; s < m_vControls.size(); ++s)
		{
			if(nGroupID != m_vControls[s].nGroupID)
				::EnableWindow(m_vControls[s].hWnd, TRUE);
		} // for
		break;
	case SWS_DISABLE:
		for(s = 0; s < m_vControls.size(); ++s)
		{
			if(nGroupID != m_vControls[s].nGroupID)
				::EnableWindow(m_vControls[s].hWnd, FALSE);
		} // for
		break;
	case SWS_SHOW:
		for(s = 0; s < m_vControls.size(); ++s)
		{
			if(nGroupID != m_vControls[s].nGroupID)
				::ShowWindow(m_vControls[s].hWnd, SW_SHOW);
		} // for
		break;
	case SWS_HIDE:
		for(s = 0; s < m_vControls.size(); ++s)
		{
			if(nGroupID != m_vControls[s].nGroupID)
				::ShowWindow(m_vControls[s].hWnd, SW_HIDE);
		} // for
		break;
	default:
		break;
	} // switch

	// And switch group reqired
	SwitchControls(nGroupID, nState);
}

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