Click here to Skip to main content
15,892,253 members
Articles / Desktop Programming / MFC

The alxBase classes for work with DBF files

Rate me:
Please Sign up or sign in to vote.
5.00/5 (22 votes)
5 Nov 20021 min read 363.4K   3.8K   57  
The alxBase classes for work with dbf files.
// ALXEditCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "AdvButton.h"
#include "resource.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAdvButton

CAdvButton::CAdvButton()
{
}

CAdvButton::~CAdvButton()
{
}


BEGIN_MESSAGE_MAP(CAdvButton, CButton)
	//{{AFX_MSG_MAP(CAdvButton)
	ON_CONTROL_REFLECT(BN_CLICKED, OnClicked)
	ON_WM_KILLFOCUS()
	ON_WM_KEYDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAdvButton message handlers

BOOL CAdvButton::ActivateCtrl(int x, int y, int cx, int cy)
{
	MoveWindow(max(x,x+(cx-cy)),y+1,min(cx,cy),cy-1);
	EnableWindow(TRUE);
	ShowWindow(SW_SHOW);
	CButton::SetFocus();
	return TRUE;
}

BOOL CAdvButton::DeactivateCtrl()
{
	EnableWindow(FALSE);
	ShowWindow(SW_HIDE);
	MoveWindow(0,0,0,0);
	return TRUE;
}

void CAdvButton::SetData(CELL_DATA CtrlData)
{
	m_Data = CtrlData;
	return;
}

CELL_DATA CAdvButton::GetCellData()
{
	return m_Data;
}

BOOL CAdvButton::IsActive()
{
	return IsWindowEnabled();
}

BOOL CAdvButton::DestroyCtrl()
{
	return DestroyWindow();
}

BOOL CAdvButton::CreateCtrl(DWORD dwStyle, CWnd *pParentWnd, UINT nID)
{
	CRect rectCtrl(0,0,0,0);
	return	Create("",dwStyle,rectCtrl,pParentWnd,nID);
}

void CAdvButton::SetFontCtrl(CFont *pFont, BOOL bRedraw)
{
	SetFont(pFont,bRedraw);
}

BOOL CAdvButton::EnableCtrl(BOOL bEnable)
{
	return	EnableWindow(bEnable);
}
BOOL CAdvButton::PreTranslateMessage(MSG* pMsg) 
{
	if(pMsg->message==WM_KEYDOWN)
	{
		switch (LOWORD(pMsg->wParam))
		{
			case VK_DOWN: case VK_UP: case VK_HOME: case VK_END: case VK_PRIOR: case VK_NEXT: case VK_LEFT: case VK_RIGHT: case VK_RETURN: case VK_TAB:
				CAdvButton::GetParent()->PostMessage(WM_KEYDOWN,MAKEWPARAM(LOWORD(pMsg->wParam),0),pMsg->lParam);
				return TRUE;
			default:
				return CButton::PreTranslateMessage(pMsg);
		}
	}
	else
		return CButton::PreTranslateMessage(pMsg);
	
	return CButton::PreTranslateMessage(pMsg);
}

void CAdvButton::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
	CDC DC;
	DC.Attach(lpDrawItemStruct->hDC);
	if(lpDrawItemStruct->itemState & ODS_SELECTED)
		DC.DrawFrameControl(&lpDrawItemStruct->rcItem,DFC_BUTTON,DFCS_BUTTONPUSH | DFCS_PUSHED);
	else
		DC.DrawFrameControl(&lpDrawItemStruct->rcItem,DFC_BUTTON,DFCS_BUTTONPUSH);
	int OldMode = DC.GetBkMode();
	DC.SetBkMode(TRANSPARENT); 
	DC.DrawText("...", &lpDrawItemStruct->rcItem, DT_CENTER | DT_VCENTER);
	DC.SetBkMode(OldMode); 
}

void CAdvButton::OnClicked() 
{
	GetParent()->PostMessage(WM_COMMAND,IDC_ADVBUTTON,0);
}

void CAdvButton::OnKillFocus(CWnd* pNewWnd) 
{
	CButton::OnKillFocus(pNewWnd);
	
	CWnd* pWnd = GetParent();
	if(pWnd != pNewWnd && pWnd != NULL)
		if(pNewWnd != NULL)
			pWnd->SendMessage(WM_KILLFOCUS, (WPARAM)pNewWnd->m_hWnd,0);
		else
			pWnd->SendMessage(WM_KILLFOCUS, NULL,0);

}


void CAdvButton::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	if(nChar = VK_F3)
		GetParent()->PostMessage(WM_COMMAND,IDC_ADVBUTTON,0);
	else
		CButton::OnKeyDown(nChar, nRepCnt, nFlags);
}

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
Year of birth - 1974.
Eeducation - was ended by Kaliningrad State University in 1997.
Now I work as the engineer-programmer in Kaliningrad (RUSSIA).

Comments and Discussions