Click here to Skip to main content
15,897,094 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I mapped one edit box control to EN_CHANGE event.Event handler function is created.If i opened my application,along with OnInitialUpdate, handler function is also calling. But handler is called whenever that corresponding event occured.

In my code,event handler is calling every time of App opening.
please solve my problem.

What I have tried:

Data.cpp
C++
OnInitialUpdate()
{
}
OnChangeEdtData()
{
}

Both functions are calling when i am trying to open app
Posted
Updated 29-Sep-16 5:05am
v2
Comments
Richard MacCutchan 29-Sep-16 6:31am    
Where is the actual mapping of messages to these functions.

1 solution

The EN_CHANGE notification is send whenever the text is changed by user input or by setting the text using SetWindowText() / WM_SETTEXT for single line edit controls.

You have probably one or more places where the edit control is initialised when the parent window (a view in your case) is created.

A possible solution would be adding a member variable to your view class:
C++
// Header file
class CMyView : CView
{
    // ...
    bool m_bIgnoreChgEdtData;
    // ...
};

// Source file
void CMyView::OnitialUpdate()
{
    m_bIgnoreChgEdtData = true;
    // Perform initialisation here.
    // Note that calling CView::OnitialUpdate calls OnUpdate()
    // If you have implemented CMyView::OnUpdate() use similar code
    //  there too.
    m_bIgnoreChgEdtData = false;
}

void CMyView::OnChangeEdtData()
{
    if (!m_bIgnoreChgEdtData)
    {
        // Handle change here
    }
}

To avoid executing the handler operations when calling SetWindowText() for the edit control somewhere in your code, do it the same way:
C++
void CMyView::setEdt(LPCTSTR str)
{
    m_bIgnoreChgEdtData = true;
    m_edtData.setWindowText(str);
    m_bIgnoreChgEdtData = false;
}
 
Share this answer
 
Comments
manikanta3 30-Sep-16 9:54am    
thanks to ur solution.From oninitialupdate(),i am calling one function,in that i am using setwindowtext for m_edtData.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900