标签:duilib richedit directui duisharp troy
在duilib开发中,小伙伴会因为CEditUI的各种问题,而转为使用CRichEditUI来代替。但是CRichEditUI控件却不支持文字变化通知事件,下面通过简单几行代码让RichEdit支持文字变化事件。
在UIRichEdith.cpp文件中搜索::OnTxNotify,然后使用以下代码替换此函数:
void CRichEditUI::OnTxNotify(DWORD iNotify, void *pv)
{
switch(iNotify)
{
case EN_CHANGE:
{
GetManager()->SendNotify(this, DUI_MSGTYPE_TEXTCHANGED);
break;
}
case EN_DROPFILES:
case EN_MSGFILTER:
case EN_OLEOPFAILED:
case EN_PROTECTED:
case EN_SAVECLIPBOARD:
case EN_SELCHANGE:
case EN_STOPNOUNDO:
case EN_LINK:
case EN_OBJECTPOSITIONS:
case EN_DRAGDROPDONE:
{
if(pv)
{
LONG nId = GetWindowLong(this->GetManager()->GetPaintWindow(), GWL_ID);
NMHDR *phdr = (NMHDR *)pv;
phdr->hwndFrom = this->GetManager()->GetPaintWindow();
phdr->idFrom = nId;
phdr->code = iNotify;
if(SendMessage(this->GetManager()->GetPaintWindow(), WM_NOTIFY, (WPARAM) nId, (LPARAM) pv))
{
}
}
}
break;
}
}
好了,需要的小伙伴赶紧试试吧!
duilib中Richedit如何支持TextChanged
标签:duilib richedit directui duisharp troy
原文地址:http://blog.csdn.net/duisharp/article/details/45395837