动态调整RichEdit控件的大小的错误代码
用如下代码动态调整RichEdit控件的大小,请问哪里错了??void CNoteBookDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
SetEditRect();
}
void CNoteBookDlg::SetEditRect()
{
CRect rectClient;
GetWindowRect(rectClient);
ScreenToClient(rectClient);
int nTop = rectClient.top;
int nLeft = rectClient.left;
int nWidth = rectClient.Width();
int nHeight = rectClient.Height();
GetDlgItem(IDC_RICHEDIT_MAIN)->MoveWindow(nTop, nLeft, nWidth, nHeight);
}
//IDC_RICHEDIT_MAIN是RichEdit的ID。RichEdit已使用AfxInitRichEdit()初始化。
//编译能通过,但运行时会出错。
请高手帮忙,谢谢了!