CRichEditCtrl随父窗口改变大小

在头文件中添加

afx_msg void OnSize(UINT nType, int cx, int cy);

在cpp文件中添加

BEGIN_MESSAGE_MAP(CCommandView, CScrollView)
 //{{AFX_MSG_MAP(CCommandView)
 ON_WM_DESTROY()
 ON_WM_KEYDOWN()
 ON_WM_SIZE()
 ON_MESSAGE(WM_MY_MESSAGE, GetEditMsg)
// ON_REGISTERED_MESSAGE(WM_MY_MESSAGE, GetEditMsg) //定义消息映射

 //}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CCommandView::OnInitialUpdate()
{
 CScrollView::OnInitialUpdate();
 ::AfxInitRichEdit2();

 //m_TransmitLogsArray.Add("this is log.");

 SetScrollSizes(MM_TEXT, CSize(0, 0));

 
 GetClientRect(&m_rect);

 m_InputCmdEdit = new CEditComm();
 m_EditView = new CRichEditCtrlEx();

 m_InputCmdEdit->Create(WS_CHILD | WS_VISIBLE | WS_BORDER , CRect(0, 0, 5000, 23 ), this, WM_USER+1);
 
 /*m_EditView->Create(WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_HSCROLL | WS_VSCROLL| WS_TABSTOP | WS_BORDER,
  CRect(0, 25, m_rect.left+m_rect.Width() + 1000, m_rect.top+m_rect.Height()), this, WM_USER+2);*/
 m_EditView->Create(WS_VISIBLE|WS_CHILD|WS_CLIPCHILDREN|ES_WANTRETURN|ES_MULTILINE|WS_VSCROLL|ES_READONLY | WS_BORDER,
  CRect(m_rect.left, m_rect.top+25, m_rect.left+m_rect.Width() + 1000, m_rect.top+m_rect.Height()), this, WM_USER+2);

}

void CCommandView::OnSize(UINT nType, int cx, int cy)
{
 if (nType == SIZE_MINIMIZED)
  return;  //最小化什么也不做

 if (m_EditView && m_EditView->GetSafeHwnd() != NULL)
 {
  CRect rect;
  GetWindowRect(&rect);
  ScreenToClient(&rect);
  rect.DeflateRect(0, 25, 0, 0);

  m_EditView->MoveWindow(rect);
  
 }
 GetClientRect(&m_rect);
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值