Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8193315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:26:23+00:00 2026-06-07T04:26:23+00:00

I am creating a MFC program using the document/view architecture. In the view I

  • 0

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,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:26:25+00:00Added an answer on June 7, 2026 at 4:26 am

    You have to handle the EN_KILLFOCUS notification code in the parent window. You shouldn’t have to derive from CEdit to do that.

    EN_KILLFOCUS notification code

    UPDATE:

    The parent window of the edit control receives this notification code
    through a WM_COMMAND message.

    wParam: The LOWORD contains the identifier of the edit control. The
    HIWORD specifies the notification code.

    lParam: – Handle to the edit control.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a Windows Mobile 6 application using MFC Single Document Interface with CFormView
There's a bunch of special macros that MFC uses when creating dialogs, and in
I have an MFC application (using a legacy library that I can't change). When
I'm creating a preferences form in VC++ MFC, and I have several textfields that
Do you know any tutorial for creating MFC ActiveX objects that can be used
Sample code that shows how to create threads using MFC declares the thread function
Creating a class at runtime is done as follows: klass = Class.new superclass, &block
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
Creating a simple RPG game, first time using XNA. Trying to get my character

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.