我生成了一个单文档的程序,我要实现的是在单文档的view中动态生成一个按钮button,然后鼠标拖动按钮的效果。现在的问题是能动态生成按钮,但是无法拖动,请高人帮忙看看,代码是:
void CText_2View::OnInitialUpdate() 
{
CView::OnInitialUpdate();
CButton *m_pButton=new CButton;   
ASSERT_VALID(m_pButton);   
m_pButton->Create(_T("Title"),WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,CRect(20,20,100,100),this,IDC_MYBUTTON);   
// TODO: Add your specialized code here and/or call the base class
}
void CText_2View::OnLButtonUp(UINT nFlags, CPoint point) 
{
// TODO: Add your message handler code here and/or call default
Mou=FALSE;
ReleaseCapture();
CView::OnLButtonUp(nFlags, point);
}void CText_2View::OnMouseMove(UINT nFlags, CPoint point) 
{
// TODO: Add your message handler code here and/or call default
CRect rect,rt;
GetClientRect(&rt);
if(Mou)
{
if(rect.PtInRect(point))
{
m_pButton->GetClientRect(&rt);
rt.left = point.x;
rt.right = rt.right + point.x;
rt.top = point.y;
rt.bottom = rt.bottom + point.y;
m_pButton->MoveWindow(&rt);
}
}

CView::OnMouseMove(nFlags, point);
}void CText_2View::OnLButtonDown(UINT nFlags, CPoint point) 
{
// TODO: Add your message handler code here and/or call default
Mou=TRUE;
SetCapture();
CView::OnLButtonDown(nFlags, point);
}