问题如下:
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:如果在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中:在GetWindowRect( &rect ); 的后面加一句: rect.top = 0; rect.left = 0;
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);
}