I am creating a MFC program using the document/view architecture. In the view I call on a cell class that extends CEdit to draw a text box. That works fine, however, when I try to catch a lose focus message for that text box nothing happens. I tried to overwrite PreTranslateMessage but that didn't work.
Here's the code in the CGridView.cpp class:
void CGridView::OnInsertText()
{
CWnd* pParentWnd = this;
CellText* pEdit = new CellText(&grid, pParentWnd);
Invalidate();
UpdateWindow();
}
the CellText.cpp:
CellText::CellText(Grid *pgrid, CWnd* pParentWnd)
{
int *pcoordinates = pgrid->GetSelectedCellCoodrinates();
cedit.Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, CRect(*pcoordinates+10, *(pcoordinates+1)+10, *(pcoordinates+2)-10, *(pcoordinates+3)-10), pParentWnd, 1);
cell = pgrid->GetSelectedCell();
pgrid->SetCellType(cell, "text");
grid = pgrid;
}
BEGIN_MESSAGE_MAP(CellText, CEdit)
ON_WM_KILLFOCUS()
ON_WM_KEYDOWN()
END_MESSAGE_MAP()
// CellText message handlers
void CellText::OnKillFocus(CWnd* pNewWnd)
{
CEdit::OnKillFocus(pNewWnd);
CString str;
GetWindowTextW(str);
grid->SetCellText(cell, str);
cedit.DestroyWindow();
}
BOOL CellText::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam==VK_UP)
{
}
}
return CWnd::PreTranslateMessage(pMsg);
}
When I debug, the onkillfocus and pretranslatemessage aren't called at all.
Thanks,