Click here to Skip to main content
15,886,788 members
Articles / Desktop Programming / MFC

DTX - Database Toolbox For MFC Ver 1.8 (Freeware Version)

Rate me:
Please Sign up or sign in to vote.
3.88/5 (8 votes)
2 Apr 20024 min read 106.4K   3.6K   56  
DTX is a set of classes for editing and automatic read, write and display of datatabase fields, as well as 70+ ready to use classes
// dbcheckbox.cpp : implementation file
//

#include "stdafx.h"
#include "dbcheckbox.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDBCheckBox

CDBCheckBox::CDBCheckBox()
	: CDTXEditBase(NULL)
{
	CDTXEditBase::SetOwner(this);
}

CDBCheckBox::~CDBCheckBox()
{
}


BEGIN_MESSAGE_MAP(CDBCheckBox, CButton)
	//{{AFX_MSG_MAP(CDBCheckBox)
	ON_WM_KILLFOCUS()
	ON_WM_SHOWWINDOW()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDBCheckBox message handlers

void CDBCheckBox::TableDataChange()
{
	if(GetSafeHwnd() && !m_EditField.IsEmpty())
	{
		DTXField* nField = GetField();
		if(nField && !nField->m_FieldName.IsEmpty())
		{
			if(GetCheck() != nField->boolVal)
				SetCheck(nField->boolVal);
			if(nField->m_Kind == dtxfkCalculated)
				EnableWindow(false);
		}
	}
}

void CDBCheckBox::TableClosed()
{
	if(GetSafeHwnd())
	{
		SetCheck(0);
		EnableWindow(false);
	}
}

void CDBCheckBox::OnKillFocus(CWnd* pNewWnd) 
{
	DTXField* nField = GetField();
	if(nField && !nField->m_FieldName.IsEmpty())
	{
		if(GetCheck() != nField->boolVal)
			SetFieldValue(GetCheck() == 0 ? _T("FALSE") : _T("TRUE"));
	}
	CButton::OnKillFocus(pNewWnd);
}

void CDBCheckBox::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	DTXField* nField = GetField();
	if(nField && !nField->m_FieldName.IsEmpty())
	{
		if(GetCheck() != nField->boolVal)
			SetCheck(nField->boolVal);
	}
	CButton::OnShowWindow(bShow, nStatus);
}

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
Turkey Turkey
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions