Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Address Book

, 6 Aug 2000 CPOL
Address Book application
// GfxInComboStatic.cpp : implementation file
//

#include "stdafx.h"
#include "Address.h"


#include "GfxInComboStatic.h"
#include "GfxInCombo.h"

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

/////////////////////////////////////////////////////////////////////////////
// CGfxInComboStatic

CGfxInComboStatic::CGfxInComboStatic()
{
	pCombo = NULL;
	crColor = GetSysColor(COLOR_WINDOWTEXT);
}

CGfxInComboStatic::~CGfxInComboStatic()
{
}


BEGIN_MESSAGE_MAP(CGfxInComboStatic, CStatic)
	//{{AFX_MSG_MAP(CGfxInComboStatic)
	ON_WM_KILLFOCUS()
	ON_WM_ERASEBKGND()
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGfxInComboStatic message handlers

void CGfxInComboStatic::OnKillFocus(CWnd* pNewWnd) 
{
	CStatic::OnKillFocus(pNewWnd);
	if (pNewWnd != GetParent() && !(GetParent()->IsChild(pNewWnd))) 
		GetParent()->DestroyWindow();
}

BOOL CGfxInComboStatic::OnEraseBkgnd(CDC* pDC) 
{
	CRect rc;
	GetClientRect(rc);
	pDC->FillSolidRect(rc, GetSysColor(COLOR_WINDOW));
	return true;	
}

void CGfxInComboStatic::OnPaint() 
{
	CPaintDC dc(this);

	CFont * pf = GetFont();
	CFont  * of = dc.SelectObject(pf);
	CRect rc;
	GetClientRect(rc);
	dc.FillSolidRect(rc, GetSysColor(COLOR_WINDOW));
	int obk = dc.SetBkMode(TRANSPARENT);
	CString cs;
	GetWindowText(cs);
	dc.TextOut(0,0,cs);
	dc.SetBkMode(obk);
	dc.SelectObject(of);
}

BOOL CGfxInComboStatic::PreTranslateMessage(MSG* pMsg) 
{
	if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_CHAR)
	{
		if (pMsg->wParam == VK_UP)   pCombo->SetCurSel(pCombo->iCurSel - 1);
		if (pMsg->wParam == VK_DOWN) pCombo->SetCurSel(pCombo->iCurSel + 1);
		if (((char) pMsg->wParam >= 'a' && (char) pMsg->wParam >= 'z') || 
			((char) pMsg->wParam >= 'A' && (char) pMsg->wParam >= 'Z') ||
			((char) pMsg->wParam >= '0' && (char) pMsg->wParam >= '9'))
		{
			CString cs = pCombo->FindFromCharPressed((char) pMsg->wParam);
			if (cs != "") SetWindowText(cs);
		}
				
		::TranslateMessage(pMsg);
		::DispatchMessage(pMsg);
		return TRUE;
	}
	
	return CStatic::PreTranslateMessage(pMsg);
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Xavier John
Software Developer
United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141030.1 | Last Updated 7 Aug 2000
Article Copyright 1999 by Xavier John
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid