惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
F
Full Disclosure
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
L
LangChain Blog
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
GbyAI
GbyAI
Y
Y Combinator Blog
博客园 - Franky
WordPress大学
WordPress大学
Apple Machine Learning Research
Apple Machine Learning Research
A
About on SuperTechFans
Blog — PlanetScale
Blog — PlanetScale
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
IT之家
IT之家
Jina AI
Jina AI
N
Netflix TechBlog - Medium
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
腾讯CDC
H
Help Net Security
H
Heimdal Security Blog
J
Java Code Geeks
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
The Exploit Database - CXSecurity.com
The Register - Security
The Register - Security
大猫的无限游戏
大猫的无限游戏
T
Threatpost
B
Blog RSS Feed
T
Threat Research - Cisco Blogs
Microsoft Security Blog
Microsoft Security Blog
S
Securelist
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog
量子位
AWS News Blog
AWS News Blog
Project Zero
Project Zero
P
Proofpoint News Feed
Cisco Talos Blog
Cisco Talos Blog
Spread Privacy
Spread Privacy
S
Schneier on Security

博客园 - 三毛

VS2008 中无法使用ACTIVEX控件的解决 - 三毛 - 博客园 #pragma pack(push,1)与#pragma pack(1)的区别 由HEAP Corruption DETECTED查到的 Run-Time Check Failure #N 关于CStdioFile奇怪的"错误" [转]利用处理程序错误攻击(下) [转]TCP/IP攻击原理分析总结 [转]利用处理程序错误攻击(上) ACE学习笔记--持续更新中 - 三毛 - 博客园 [转]VC使用CRT调试功能来检测内存泄漏 [转]RSA算法简介 IOCP学习笔记 解决:Can't connect to local MySQL server through socket LINUX学习笔记:在Linux中设置IP地址 在MySQL中级联删除数据 NHibernate笔记 MySQL学习笔记 [转]洗衣除渍的窍门 [转]中国街头骗术大全 ---------------------献给经验不足的朋友
[转]在MFC中的文档视图中对视图使用RichEdit2--来自CodeGuru
三毛 · 2007-05-14 · via 博客园 - 三毛

The following is an example of rich edit2.0 based on the default SD rich edit project.
Please email me for source code.
1.revise PreCreateWindows
BOOL CRich20DocViewView::PreCreateWindow(CREATESTRUCT& cs)
{
 // TODO: Modify the Window class or styles here by modifying
 //  the CREATESTRUCT cs
// return CRichEditView::PreCreateWindow(cs);
 m_strClass="RichEdit20A";
 BOOL nR=CRichEditView::PreCreateWindow(cs);
 LoadLibraryA("RICHED20.DLL");
 return nR;
}
2. revise OnDestory
void CRich20DocViewView::OnDestroy()
{
 // Deactivate the item on destruction; this is important
 // when a splitter view is being used.
//   CRichEditView::OnDestroy();
   COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
   if (pActiveItem != NULL && pActiveItem->GetActiveView() == this)
   {
      pActiveItem->Deactivate();
      ASSERT(GetDocument()->GetInPlaceActiveItem(this) == NULL);
   }
   CRichEditView::OnDestroy();
}
3. Enable auto URL detect in OnInitialUpdate()
 long lENM=GetRichEditCtrl().GetEventMask();
 lENM|=ENM_LINK;
 GetRichEditCtrl().SetEventMask(lENM);
 BOOL bEnable=1;
 ::SendMessage(m_hWnd,EM_AUTOURLDETECT,bEnable,0);
4. URL left-button_dwon open with notify message
 ON_NOTIFY_REFLECT_EX(EN_LINK, OnLink ) 
 afx_msg void OnLink( NMHDR* in_pNotifyHeader, LRESULT* out_pResult );
 void CRich20DocViewView::OnLink( NMHDR* in_pNotifyHeader, LRESULT* out_pResult )
{
  ENLINK * pLink=(ENLINK*) in_pNotifyHeader;
  if(pLink->msg==WM_LBUTTONDOWN)
  {
  GetRichEditCtrl().SetSel(pLink->chrg);
  CString str=GetRichEditCtrl().GetSelText();
  ShellExecute( this->GetSafeHwnd(), _T( "open" ), str, NULL, NULL, SW_SHOWNORMAL ) ;
  }
}

5. To print correctly, revise OnPrint. Without the following, there might be a non-stop print with blank pages)
void CRich20DocViewView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
 // TODO: Add your specialized code here and/or call the base class
 ASSERT_VALID(this);
 ASSERT_VALID(pDC);
 ASSERT(pInfo != NULL);
 ASSERT(pInfo->m_bContinuePrinting);

 UINT nPage = pInfo->m_nCurPage;
 ASSERT(nPage <= (UINT)m_aPageStart.GetSize());
 long nIndex = (long) m_aPageStart[nPage-1];

 // print as much as possible in the current page.
 nIndex = PrintPage(pDC, nIndex, 0xFFFFFFFF);
//nIndex got above hasn't take "return" into account
//The following codes add nIndex when there are any new lines
 int nLength=GetTextLength();
 CString strRich;
 GetRichEditCtrl().GetWindowText(strRich);
 int nS=0;
 while(nS!=-1)
 {
  nS=strRich.Find("\r\n",nS);
  if(nS!=-1)
  {
   nLength--;
   nS++;
  }

 }
 //END adding nIndex
 
 //other error that might cause non-stop print
 if(m_nIndex==nIndex)
  nLength-=10000;
 m_nIndex=nIndex;
 //end other erro

 if (nIndex >= nLength)//GetTextLength()
 {
  TRACE0("End of Document\n");
  pInfo->SetMaxPage(nPage);
 }

 // update pagination information for page just printed
 if (nPage == (UINT)m_aPageStart.GetSize())
 {
  if (nIndex < nLength)//GetTextLength()
   m_aPageStart.Add(nIndex);
 }
 else
 {
  ASSERT(nPage+1 <= (UINT)m_aPageStart.GetSize());
  ASSERT(nIndex == (long)m_aPageStart[nPage+1-1]);
 } 
// CRichEditView::OnPrint(pDC, pInfo);
}