RichEdit20A控件内容的外部获取方式

因需要想从外部获取一个RichEdit20A的控件的内容,先后试过虚拟ctrl+c方式与读取进程内存方式,都未能正确获得所需内容。

最后还是参考MSDN,发现了很简单的方法,

   TCHAR buf[200];
   GETTEXTEX gt;
   gt.cb=200;
   gt.flags=GT_DEFAULT;
   gt.codepage=CP_ACP;
   gt.lpDefaultChar=NULL;
   gt.lpUsedDefChar=NULL;
   SendMessage(hEdit,EM_GETTEXTEX,(WPARAM)&gt,(LPARAM)buf);

呵呵 碰到问题还是google+msdn最好使.....

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
来源: http://www.codeguru.com/cpp/controls/richedit/article.php/c2389/CRichEditCtrlEx--Replacing-RICHEDIT-control-with-RichEdit20A.htm While writing a dev notes Visual Studio plug in, I wanted the rich edit control in a dialog to understand URL's so developers could add links to sites and email addresses. After talking to "Long John", he led me to the easy way of doing it, and now I am posting the work for others. Basically this requires CRichEditCtrlEx to use the new rich edit DLL RICHED20.DLL. The first thing to do it change the window class name of the rich edit controls from "RICHEDIT" to "RichEdit20A" in the *.rc file. Next, we create a class derived from CRichEditCtrl called CRichEditCtrlEx and override the Create() method: class CRichEditCtrlEx : public CRichEditCtrl { public: CRichEditCtrlEx(); virtual ~CRichEditCtrlEx(); // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL( CRichEditCtrlEx ) public: virtual BOOL Create( DWORD in_dwStyle, const RECT& in_rcRect, CWnd* in_pParentWnd, UINT in_nID ); //}}AFX_VIRTUAL // Generated message map functions protected: //{{AFX_MSG( CRichEditCtrlEx ) //}}AFX_MSG DECLARE_MESSAGE_MAP() }; Now implement the Create() method like this: Post a comment Email Article Print Article Share Articles Digg del.icio.us Newsvine Facebook Google LinkedIn MySpace Reddit Slashdot StumbleUpon Technorati Twitter Windows Live YahooBuzz FriendFeed BOOL CRichEditCtrlEx::Create(DWORD in_dwStyle, const RECT& in_rcRect, CWnd* in_pParentWnd, UINT in_nID) { if( ! ::AfxInitRichEditEx() ) { return FALSE ; } CWnd* l_pWnd = this ; return l_pWnd->Create( _T( "RichEdit20A" ), NULL, in_dwStyle, in_rcRect, in_pParentWnd, in_nID ); } This is almost exactly what is in CRichEditCtrl::Create(), except the different window class name, and the call to AfxInitRichEdit() has been changed to AfxInitRichEditEx() which first calls AfxInitRichEdit (we do not want to break the normal CRichEditCtrl). In the RichEditCtrlEx.h file, you need to add the DLL holder class and function prototype: class _AFX_RICHEDITEX_STATE { public: _AFX_RICHEDITEX_STATE(); virtual ~_AFX_RICHEDITEX_STATE(); HINSTANCE m_hInstRichEdit20 ; }; BOOL PASCAL AfxInitRichEditEx(); Now, in the source code, add the implementation: _AFX_RICHEDITEX_STATE::_AFX_RICHEDITEX_STATE() { m_hInstRichEdit20 = NULL ; } _AFX_RICHEDITEX_STATE::~_AFX_RICHEDITEX_STATE() { if( m_hInstRichEdit20 != NULL ) { ::FreeLibrary( m_hInstRichEdit20 ) ; } } _AFX_RICHEDITEX_STATE _afxRichEditStateEx ; BOOL PASCAL AfxInitRichEditEx() { if( ! ::AfxInitRichEdit() ) { return FALSE ; } _AFX_RICHEDITEX_STATE* l_pState = &_afxRichEditStateEx ; if( l_pState->m_hInstRichEdit20 == NULL ) { l_pState->m_hInstRichEdit20 = LoadLibraryA("RICHED20.DLL") ; } return l_pState->m_hInstRichEdit20 != NULL ; }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值