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

  • Home
  • SEARCH
  • 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 8177415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:30:11+00:00 2026-06-06T23:30:11+00:00

I have a CEdit derived control that displays the string N/A when the undelying

  • 0

I have a CEdit derived control that displays the string “N/A” when the undelying data is null. I recently added code to empty the control(SetWindowText(“”);) when it gains focus and set if back to “N/A”(SetWindowText(“N/A”)) when the focus is lost if the user left the control empty.

The only problem is that setting the window text to “” or “N/A” triggers EN_CHANGE, so my dialog thinks that the data has changed.

How can I avoid EN_CHANGE from being fired when calling SetWindowText (WM_SETTEXT)?

NOTES

-I know I can set the edit control to Multiline=TRUE but that’s not accpectable for me.

-My application is MBCS so I can’t use SetCueBanner

-I want an elegant solution. Setting the parent window to NULL temporarily is not an elegant solution.

EDIT:

-I want the solution to be in my custom control, not in each dialog

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-06T23:30:12+00:00Added an answer on June 6, 2026 at 11:30 pm

    I finally found a suitable solution to my problem.

    First, I added a flag to my derived control’s header file and I initialized it to false in the constructor

    bool m_bNoEnChange;
    

    I overrode the OnChildNotify in my derived control’s header file and in the implementation, I checked for the WM_COMMAND message with the EN_CHANGE parameter. I then returned TRUE to prevent the message from being sent to the parent(dialog/page)

    virtual BOOL OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult);
    

    BOOL CADEdit::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult) 
    {
        if(message == WM_COMMAND && HIWORD(wParam) == EN_CHANGE)
        {
            //If the flag is set, don't send the message to the parent window
            if(m_bNoEnChange)
                return TRUE;
        }
    
        return CEdit::OnChildNotify(message, wParam, lParam, pLResult);
    }
    

    Finally, when the control gains and loses focus, I wrapped the problematic SetWindowText with my flag

    m_bNoEnChange = true;
    SetWindowText(_T(""));
    m_bNoEnChange = false;
    

    This solution is the best in my case because I don’t have to modify each dialog.

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

Sidebar

Related Questions

I have a CEdit control that I want to be able to take time
How do I have a CEdit control display placeholder text when it's empty, similar
I have the following segment of code where m_edit is a CEdit control: TCHAR
I have added a simple Cedit control to my dialog and have an OnEnChangeEdit
I have the following code, m_edit is a MFC CEdit (I know I would
I have a method inside my derived class that I don't have in my
I have CEdit control and I don't want any text to be selected by
My site is going to have a credit system that basically works a lot
I have a web site that work with external Credit Card Processing (cybersource) when
I have to handle some sensitive data in my application, such as passwords, credit

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.