问题如下:
     1:如果在OnSize里添加下面代码后,窗口的整个边框为0(包括标题栏),只剩下了客户区
 问题是最大化时,窗口不是在最上面,空了标题标的位置,Rect.top =标题标的高度,Rect.left =0,这时用SPY看窗口的位置
客户区的坐标ClientRect.top = 25,ClientRect.left = 3;这个怎么解决????
// TODO: Add your message handler code here
 if ( cx > 0 && cy > 0 )
    {
        // Here we calculate the resulting window size from the passed client size
        CRect rect( 0, 0, cx, cy );
        GetWindowRect( &rect );
 
        // Here we create the rounded region - you can adjust the 'rounding' using a different 'r'
        CRgn rgn;
        rgn.CreateRoundRectRgn( GetSystemMetrics(SM_CXBORDER) + GetSystemMetrics(SM_CXDLGFRAME),   GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYDLGFRAME) + GetSystemMetrics(SM_CYCAPTION), 
rect.Width()-1, rect.Height()-1, r, r );
        SetWindowRgn( (HRGN)rgn.Detach(), TRUE );
    }
   2:上面的不实现,如果只实现OnNcCalcSize,代码如下,这时运行程序后,窗口标题栏也不见了,但是当刷新窗口时,标题栏和边框又会重画上去,但是这时窗口还是不能拖动的,用SPY看时,NC和客户区是重合的,Rect.top = 0,rect.left =0,客户区和非客户区的大小和坐标是一样的,请问这个重画的怎么解决???
        if(bCalcValidRects)
{
lpncsp->rgrc[0].left = lpncsp->rgrc[0].left - GetSystemMetrics(SM_CXBORDER)- GetSystemMetrics(SM_CXDLGFRAME);
lpncsp->rgrc[0].right = lpncsp->rgrc[0].right + GetSystemMetrics(SM_CXBORDER)+ GetSystemMetrics(SM_CXDLGFRAME);
lpncsp->rgrc[0].top = lpncsp->rgrc[0].top - GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYCAPTION);
lpncsp->rgrc[0].bottom = lpncsp->rgrc[0].bottom + GetSystemMetrics(SM_CYBORDER)+GetSystemMetrics(SM_CYDLGFRAME);
lpncsp->rgrc[1] = lpncsp->rgrc[0];
}        CDialog::OnNcCalcSize(bCalcValidRects, lpncsp);    感觉QQ都是用这两个方法来实现的窗口的,QQ主窗口是用第二种方法实现的,其它窗口均是用第一方法实现的

解决方案 »

  1.   

    晕,楼主这个问题还怪……
    方法1中:在GetWindowRect( &rect ); 的后面加一句:  rect.top = 0; rect.left = 0;
      

  2.   

    不好意思,我没说明白,是这样的,QQ窗口风格是带标题栏和边框的,但是他用RGN方法来把标题和边框去掉了,在客户区来画标题和边框,这样其实方便不少,好多消息不用自己处理了,现在我也想用这方法来处理,我说的两种方法都能实现,遇到些问题,2楼的给的方法加上没用的
      

  3.   

    刚刚查看了下QQ2009主窗体,客户区跟窗口区一样大,应该不是用Rgn法的。印象中,最早用带标题边框风格且Rgn法的是Windows Media Player,然后是MSN。
      

  4.   

    难道SetWindwoRgn函数不能使客户区充满屏幕啊? 标题栏的位置还是空出来了?  没试验过呢~~
      

  5.   

    int ty=3;
    CRect   m_rect;   
    GetWindowRect(&m_rect);  
    int iHight = m_rect.Height();
    int iWidth = m_rect.Width();
    int recordy=m_rect.left;
    int recordx=m_rect.top;
    for(int i=0;i<3;i++)
    {
    m_rect.left=recordy;
    m_rect.top=recordx;
    m_rect.top = m_rect.top + ty;  
    m_rect.left = m_rect.left - ty;
    SetWindowPos(NULL  ,m_rect.left,m_rect.top,iWidth,iHight,SWP_SHOWWINDOW|SWP_NOSIZE);Sleep(35);
    m_rect.top = m_rect.top -ty;
    SetWindowPos(NULL  ,m_rect.left,m_rect.top,iWidth,iHight,SWP_SHOWWINDOW|SWP_NOSIZE  );Sleep(35);
    m_rect.top = m_rect.top -2*ty;
    SetWindowPos(NULL   ,m_rect.left,m_rect.top,iWidth,iHight,SWP_SHOWWINDOW|SWP_NOSIZE );Sleep(35);
    m_rect.left=m_rect.left+ty;
    SetWindowPos(NULL  ,m_rect.left,m_rect.top,iWidth,iHight,SWP_SHOWWINDOW|SWP_NOSIZE  );Sleep(35);
    m_rect.left=m_rect.left+2*ty;
    SetWindowPos(NULL,m_rect.left,m_rect.top,iWidth,iHight,SWP_SHOWWINDOW|SWP_NOSIZE  );Sleep(35);
    m_rect.top = m_rect.top + ty;  
    SetWindowPos(NULL  ,m_rect.left,m_rect.top,iWidth,iHight,SWP_SHOWWINDOW|SWP_NOSIZE  );Sleep(35);
    m_rect.top=m_rect.top+2*ty;
    SetWindowPos(NULL  ,m_rect.left,m_rect.top,iWidth,iHight,SWP_SHOWWINDOW|SWP_NOSIZE  );Sleep(35);
    SetWindowPos(NULL  ,recordy,recordx,iWidth,iHight,SWP_SHOWWINDOW|SWP_NOSIZE  );Sleep(35);

    }
      

  6.   

    我觉得QQ2009是直接把非客户区的大小变成0的,像拖到边框大小的可以自己模拟,这样会方便很多,只处理Client消息。
      

  7.   

    使用 SetLayeredWindowAttributes 设置 dwFlags 为 LWA_COLORKEY