问题描述
我将一个编辑框控件映射到EN_CHANGE event.Event处理函数被创建。如果我打开我的应用程序,与OnInitialUpdate一起,处理函数也在调用。但只要相应的事件发生就会调用处理程序。
在我的代码中,事件处理程序每次打开App时都会调用。
请解决我的问题。
我的尝试:
Data.cpp
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
OnInitialUpdate()
{
}
OnChangeEdtData()
{
}
当我尝试打开应用程序时,这两个函数都在调用
Both functions are calling when i am trying to open app
推荐答案
// 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
}
}
避免在调用 SetWindowText()$ c时执行处理程序操作$ c>对于代码中某处的编辑控件,以相同的方式执行:
To avoid executing the handler operations when calling SetWindowText()
for the edit control somewhere in your code, do it the same way:
void CMyView::setEdt(LPCTSTR str)
{
m_bIgnoreChgEdtData = true;
m_edtData.setWindowText(str);
m_bIgnoreChgEdtData = false;
}
这篇关于编辑框控件映射到EN_CHANGE event.event处理程序正在调用,每次在vc ++ 6.0中打开app为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!