下面代码是我的实现,我用了两个CRect类,怎么第一个是获得整个对话框的,第二个是获得指定的,怎么就是不行,求高手指点
         CRect rc;
GetClientRect(&rc);
ClientToScreen(&rc);
CRect titleRc(0,0,rc.Width()-50,rc.Height()-50);
GetClientRect(&titleRc);
if (!titleRc.PtInRect(point))
{ ClientToScreen(&titleRc);
return HTCAPTION;
}
else return CDialogEx::OnNcHitTest(point);

解决方案 »

  1.   

    这样:
    CRect   rc; 
    GetClientRect(&rc); 
    CRect   titleRc(0,0,rc.Width()-50,rc.Height()-50); 
    if   (!titleRc.PtInRect(point)) 

    return   HTCAPTION; 

    else   return   CDialogEx::OnNcHitTest(point); 
      

  2.   


    CRect rc;
    GetWindowRect(&rc);
    int nHeight = rc.Height();
    rc.bottom = rc.top + nHeight/2;
    if (rc.PtInRect(point))
    {
    return   HTCAPTION;
    }

    return CDialog::OnNcHitTest(point);窗口的上半部分可以拖动,下半部分不可以拖动
      

  3.   

    是啊,我用的是自己写的对话框类,继承自CDialogEx,是不是不一样呢