ATL Richedit文本更改事件 [英] ATL Richedit text change events

查看:72
本文介绍了ATL Richedit文本更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在尝试在ATL中创建一个由RICHEDIT派生的ActiveX控件时,我已经管理了

来成功实现了stock字体属性,谢谢你的所有帮助

就此了。

我现在停止收到文本发生变化的通知。

我选择了一个股票Text属性创建控件,将一个

OnTextChanged事件处理程序放入我的控件的主类中。这似乎永远不会被调用,即使我在

OnCreate中放置代码来适当地设置事件掩码,现在看起来像这样:

LRESULT OnCreate(UINT / * uMsg * /,WPARAM / * wParam * /,LPARAM / * lParam * /,BOOL&

/ * bHandled * /)

{

RECT rc;

GetWindowRect(& rc);

rc.right - = rc.left;

rc.bottom - = rc.top;

rc.top = rc.left = 0;

m_hLibRichEdit = LoadLibrary(_T(" RICHED32.DLL")) );

m_ctlRichEdit.Create(m_hWnd,rc);


DWORD dwEvents = m_ctlRichEdit.SendMessage(EM_GETEVENTMASK);

m_ctlRichEdit .SendMessage(EM_SETEVENTMASK,0,dwEvents | ENM_CHANGE);

返回0;

}

我尝试了另一个大头钉 - 选择了控件''在Class视图中的主类,对属性进行了
,选择了消息,并通过向导为

WM_CHAR添加了一个处理程序。它也永远不会被调用,即使我已经注意到,当我按下按键在RICHEDIT中键入文本时,它接收WM_CHAR

消息为由间谍++显示。 (WM_CHAR处理程序如下所示)


LRESULT Ctextchange :: OnChar(UINT / * uMsg * /,WPARAM / * wParam * /,LPARAM

/ * lParam * /,BOOL& / * bHandled * /)

{


ATLTRACE(_T(OnChar被解雇!)); //永远不会被打电话。


返回S_OK;

}


我现在不知所措那么有人可以提出什么建议吗?非常感谢。

Hi
In trying to create a RICHEDIT-derived ActiveX control in ATL, I''ve managed
to successfully implement the stock font property, thanks for all your help
on this.
I''m now stuck on receiving notification that the text has changed.
I selected a stock Text property when creating the control, which put an
OnTextChanged event handler into my control''s main class. This never seems to
get called, even when I put code to set the event mask appropriately in the
OnCreate, which now looks like this:
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL&
/*bHandled*/)
{
RECT rc;
GetWindowRect(&rc);
rc.right -= rc.left;
rc.bottom -= rc.top;
rc.top = rc.left = 0;
m_hLibRichEdit = LoadLibrary(_T("RICHED32.DLL"));
m_ctlRichEdit.Create(m_hWnd, rc);

DWORD dwEvents = m_ctlRichEdit.SendMessage(EM_GETEVENTMASK);
m_ctlRichEdit.SendMessage(EM_SETEVENTMASK, 0, dwEvents | ENM_CHANGE);
return 0;
}
I tried another tack - selected the control''s main class in Class view, went
to properties, chose messages, and added a handler through the wizard for
WM_CHAR. It never gets called either, even when I''ve noticed that while I''m
pressing keys to type text into the RICHEDIT, it is receiving WM_CHAR
messages as shown by Spy++. (The WM_CHAR handler is as shown below)

LRESULT Ctextchange::OnChar(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM
/*lParam*/, BOOL& /*bHandled*/)
{

ATLTRACE(_T("OnChar fired!")); //never gets called.

return S_OK;
}

I''m now at a loss, so can anybody suggest anything? Thanks ever so.

推荐答案

" Patty O''Dors" <帕******** @ discussions.microsoft.com>在消息中写道

news:85 ********************************** @ microsof t.com
"Patty O''Dors" <Pa********@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com
在尝试在ATL中创建一个由RICHEDIT派生的ActiveX控件时,我已成功实现了stock字体属性,感谢
所有帮助在这个。
我现在停止接收文本已经改变的通知。
我在创建控件时选择了一个库存Text属性,它将一个OnTextChanged事件处理程序放入我的控件中的主要课程。这个
似乎永远不会被调用,即使我在OnCreate中放置代码来适当地设置事件掩码,现在看起来像这样:
In trying to create a RICHEDIT-derived ActiveX control in ATL, I''ve
managed to successfully implement the stock font property, thanks for
all your help on this.
I''m now stuck on receiving notification that the text has changed.
I selected a stock Text property when creating the control, which put
an OnTextChanged event handler into my control''s main class. This
never seems to get called, even when I put code to set the event mask
appropriately in the OnCreate, which now looks like this:




您的消息中是否有EN_CHANGE通知的事件处理程序

map?显示此条目。

-

祝你好运,

Igor Tandetnik


"有两次,我被[国会议员]问过,''祈祷,

巴贝奇先生,如果你把错误的数字投入机器,那就是正确的

答案出来了吗?''我无法正确地理解那些可能引发这样一个问题的想法混淆。 - 查尔斯

Babbage



Do you have an event handler for EN_CHANGE notification in your message
map? Show this entry.
--
With best wishes,
Igor Tandetnik

"On two occasions, I have been asked [by members of Parliament], ''Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?'' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles
Babbage


阅读CHAIN_MSG_MAP,了解它的作用。


Brian
Read up on CHAIN_MSG_MAP and see what it does.

Brian


" Patty O''Dors" <帕******** @ discussions.microsoft.com>在消息中写道

新闻:F6 ********************************** @ microsof t.com
"Patty O''Dors" <Pa********@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com
这是整个消息地图:

BEGIN_MSG_MAP(Ctextchange)
MESSAGE_HANDLER(WM_CREATE,OnCreate)
MESSAGE_HANDLER(WM_SETFOCUS,OnSetFocus)
MESSAGE_HANDLER(WM_DESTROY,OnDestroy)
CHAIN_MSG_MAP(CComControl< Ctextchange>)
MESSAGE_HANDLER(EN_CHANGE,OnChange)//这就是我添加的
This is the whole message map:

BEGIN_MSG_MAP(Ctextchange)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
CHAIN_MSG_MAP(CComControl<Ctextchange>)
MESSAGE_HANDLER(EN_CHANGE, OnChange) //this is what I added




EN_CHANGE是以WM_COMMAND消息的形式发送的通知。你需要

想要


COMMAND_CODE_HANDLER(EN_CHANGE,OnChange)


LRESULT OnChange(WORD wNotifyCode,WORD wID,HWND hWndCtl,BOOL&

bHandled);


并在CHAIN_MSG_MAP之前移动

-

最美好的祝福,

Igor Tandetnik


有两次,我被[议会议员]问过,''祈祷,
巴贝奇先生,如果你把错误的数字输入机器,那么正确的

答案会出来吗?''我无法正确地理解那种

混淆了可能引发这样一个问题的想法。 - 查尔斯

Babbage



EN_CHANGE is a notification sent in the form of WM_COMMAND message. You
want

COMMAND_CODE_HANDLER(EN_CHANGE, OnChange)

LRESULT OnChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL&
bHandled);

And move it before CHAIN_MSG_MAP
--
With best wishes,
Igor Tandetnik

"On two occasions, I have been asked [by members of Parliament], ''Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?'' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles
Babbage


这篇关于ATL Richedit文本更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆