void CCaptureDlg::OnNcMouseMove(UINT nHitTest, CPoint point) { CRect tempMin,tempMax,tempClose,ClientRect; CWindowDC WindowDC (this); //CWindowDC类对象 CDC memDC; memDC.CreateCompatibleDC(&WindowDC); //创建内存设备环境 BITMAPINFO bInfo; CBitmap LeftLine; int x,y; GetWindowRect(ClientRect); tempMin.CopyRect(CRect(m_MinRect.left+ ClientRect.left,ClientRect.top +m_MinRect.top,m_MinRect.right+m_MinRect.left+ ClientRect.left, m_MinRect.bottom+m_MinRect.top+ClientRect.top)); //设置最小化按钮区域 tempMax.CopyRect(CRect(m_MaxRect.left+ ClientRect.left,ClientRect.top +m_MaxRect.top,m_MaxRect.right+m_MaxRect.left+ ClientRect.left, m_MaxRect.bottom+m_MaxRect.top+ClientRect.top)); //设置最大化按钮区域 tempClose.CopyRect(CRect(m_CloseRect.left+ ClientRect.left,ClientRect.top +m_CloseRect.top,m_CloseRect.right+m_CloseRect.left+ ClientRect.left, m_CloseRect.bottom+m_CloseRect.top+ClientRect.top)); //设置关闭按钮区域 if(tempMin.PtInRect(point)) //鼠标在最小化按钮上移动时,更改按钮显示的位图 { if(m_ButtonState != bsMin) { LeftLine.LoadBitmap(IDB_MINHOTBT) ; //加载最小化按钮位图资源 LeftLine.GetObject(sizeof(bInfo),&bInfo); x = bInfo.bmiHeader.biWidth; //获得位图宽度 y = bInfo.bmiHeader.biHeight; //获得位图高度 memDC.SelectObject(&LeftLine); WindowDC.StretchBlt(m_MinRect.left,m_MinRect.top,m_MinRect.right, m_MinRect.bottom,&memDC,0,0,x,y,SRCCOPY); //绘制最小化按钮 m_IsDrawForm = FALSE; m_ButtonState = bsMin; LeftLine.Detach(); } } else if(tempMax.PtInRect(point)) { if(m_ButtonState!=bsMax && m_ButtonState!=bsRes) { LeftLine.LoadBitmap(IDB_MAXHOTBT); //加载最大化按钮位图资源 LeftLine.GetObject(sizeof(bInfo),&bInfo); x = bInfo.bmiHeader.biWidth; //获得位图宽度 y = bInfo.bmiHeader.biHeight; //获得位图高度 memDC.SelectObject(&LeftLine); WindowDC.StretchBlt(m_MaxRect.left,m_MaxRect.top,m_MaxRect.right, m_MaxRect.bottom,&memDC,0,0,x,y,SRCCOPY); //绘制最大化按钮 m_IsDrawForm = FALSE; if (m_IsMax) { m_ButtonState = bsMax; } else { m_ButtonState = bsRes; } LeftLine.Detach(); } } else if(tempClose.PtInRect(point)) { if(m_ButtonState != bsClose) { LeftLine.LoadBitmap(IDB_CLOSEHOTBT); //加载关闭按钮位图资源 LeftLine.GetObject(sizeof(bInfo),&bInfo); x = bInfo.bmiHeader.biWidth; //获得位图宽度 y = bInfo.bmiHeader.biHeight; //获得位图高度 memDC.SelectObject(&LeftLine); WindowDC.StretchBlt(m_CloseRect.left,m_CloseRect.top,m_CloseRect.right, m_CloseRect.bottom,&memDC,0,0,x,y,SRCCOPY); //绘制关闭按钮 m_IsDrawForm = FALSE; m_ButtonState = bsClose; LeftLine.Detach(); } } else { if(m_IsDrawForm == FALSE) { if(m_ButtonState == bsMin) DrawDialog( FMINBUTTON); //重绘最小化按钮 else if(m_ButtonState == bsClose) DrawDialog( FCLOSEBUTTON); //重绘关闭按钮 else if(m_ButtonState == bsMax || m_ButtonState==bsRes) DrawDialog( FMAXBUTTON); //重绘最大化按钮 } m_ButtonState = bsNone; } LeftLine.DeleteObject(); ReleaseDC(&memDC); CDialog::OnNcMouseMove(nHitTest, point); }
|