// WGroupCtrl.cpp : 实现文件 // #include "stdafx.h" #include "WGroupCtrl.h" #include "resource.h" /////////////////////////////////////////////////////////////////////////////////// TUTIL_IMPEXP HCURSOR g_hHandCursor=NULL; void TUTIL_IMPEXP DrawVertText(CDC* pDC,CString sText,CPoint ptTopLeft) { pDC->SetTextAlign(TA_TOP|TA_LEFT); UString sTextU(sText); for(long i=0;iTextOut(ptTopLeft.x,ptTopLeft.y,CString((const TCHAR*)sTextMid)); ptTopLeft.y+=pDC->GetTextExtent(sTextMid).cy+1; } } void TUTIL_IMPEXP DDX_GroupStatus(CDataExchange* pDX, int nIDC, int& value) { pDX->PrepareCtrl(nIDC); HWND hWndCtrl; pDX->m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl); if (pDX->m_bSaveAndValidate) value = (int)::SendMessage(hWndCtrl, WG_MES_GETSTATUS, 0, 0L); else ::SendMessage(hWndCtrl, WG_MES_SETSTATUS, (WPARAM)value, 0L); } CRect TUTIL_IMPEXP AddExtend(CRect rect1,CRect rect2) { return CRect(min(rect1.left,rect2.left), min(rect1.top,rect2.top), max(rect1.right,rect2.right), max(rect1.bottom,rect2.bottom)); } //计算包围盒 CRect TUTIL_IMPEXP GetTotalRect(DualList &lstRect) { if(lstRect.IsEmpty()) return CRect(0,0,0,0); lstRect.MoveToFirst(); CRect rect=lstRect.GetCurData(); for(lstRect.MoveToNext();!lstRect.IsOut();lstRect.MoveToNext()) rect=AddExtend(rect,lstRect.GetCurData()); return rect; } // WGroupCtrl IMPLEMENT_DYNAMIC(WGroupCtrl, CStatic) WGroupCtrl::WGroupCtrl(int flag):WFlag(flag) ,m_bOpen(TRUE),m_bOverControl(FALSE),m_pGroup(NULL) { } WGroupCtrl::~WGroupCtrl() { } BEGIN_MESSAGE_MAP(WGroupCtrl, CStatic) ON_MESSAGE(WG_MES_GETSTATUS,OnGetStatus) ON_MESSAGE(WG_MES_SETSTATUS,OnSetStatus) ON_WM_NCHITTEST() ON_WM_PAINT() ON_WM_LBUTTONDOWN() ON_WM_LBUTTONDBLCLK() ON_WM_MOUSEMOVE() ON_WM_SETCURSOR() ON_WM_CAPTURECHANGED() END_MESSAGE_MAP() void WGroupCtrl::OnCaptureChanged(CWnd* pNewWnd) { CStatic::OnCaptureChanged(pNewWnd); if(m_bOverControl) { m_bOverControl=FALSE; Invalidate(); } } LRESULT WGroupCtrl::OnGetStatus(WPARAM, LPARAM) { return IsOpened(); } LRESULT WGroupCtrl::OnSetStatus(WPARAM bOpen, LPARAM) { if(IsOpened()!=bOpen) { if(IsOpened()) Fold(); else UnFold(); } return IsOpened(); } void WGroupCtrl::Refresh() { m_lstWinHandle.Clear(); m_lstWinRect.Clear(); } BOOL g_bLockRedraw=FALSE; void WGroupCtrl::Fold() { CClientDC dc(this); // device context for painting dc.SelectObject(GetFont()); int fontHeight; TEXTMETRIC tm; dc.GetTextMetrics(&tm); fontHeight=tm.tmHeight; if(fontHeight%2==0) fontHeight+=1; CRect rect; GetWindowRect(rect); m_nExtent=IsVert()?rect.Height():rect.Width(); CRect rectNew(rect); GetParent()->ScreenToClient(rectNew); DualList lstRect; lstRect.AddTail(rectNew); if(IsVert()) rectNew.bottom=rectNew.top+fontHeight+WG_MIN_SPACE; else rectNew.right=rectNew.left+fontHeight+WG_MIN_SPACE; //隐藏组内的窗口 if(m_lstWinHandle.IsEmpty()) { for(CWnd*pWnd=GetParent()->GetWindow(GW_CHILD);pWnd!=NULL;pWnd=pWnd->GetNextWindow()) { if(pWnd==this) continue; CRect rect1; pWnd->GetWindowRect(rect1); if(rect.PtInRect(rect1.BottomRight())&&rect.PtInRect(rect1.TopLeft())) { m_lstWinHandle<GetSafeHwnd(); ScreenToClient(rect1);//转化为相对坐标 m_lstWinRect<MoveWindow(CRect(rectNew.TopLeft(),CSize(0,0)),FALSE); //pWnd->MoveWindow(rectNew,FALSE);//使用了一个与group重合的窗口 //pWnd->ShowWindow(SW_HIDE); } } } else { for(m_lstWinHandle.MoveToFirst();!m_lstWinHandle.IsOut();m_lstWinHandle.MoveToNext()) { CWnd* pWnd=CWnd::FromHandle(m_lstWinHandle.GetCurData()); pWnd->MoveWindow(CRect(rectNew.TopLeft(),CSize(0,0)),FALSE); //pWnd->MoveWindow(rectNew,FALSE);//使用了一个与group重合的窗口 //pWnd->ShowWindow(SW_HIDE); } } //改变窗口大小 MoveWindow(rectNew,FALSE); //移动后面窗口 int nOffset=IsVert()?m_nExtent-rectNew.Height():m_nExtent-rectNew.Width(); for(CWnd*pWnd=GetParent()->GetWindow(GW_CHILD);pWnd!=NULL;pWnd=pWnd->GetNextWindow()) { if(pWnd==this) continue; CRect rect1,rectBak; pWnd->GetWindowRect(rect1); rectBak=rect1; GetParent()->ScreenToClient(rectBak); bool bMoving=false; if(IsVert()) { if(rect1.top>rect.bottom)//下方 { if(rect1.left>=rect.left&&rect1.right<=rect.right)//正下方 { rect1.bottom-=nOffset; rect1.top-=nOffset; bMoving=true; } } } else { if(rect1.left>rect.right)//右方 { if(rect1.top>=rect.top&&rect1.bottom<=rect.bottom)//正右方 { rect1.right-=nOffset; rect1.left-=nOffset; bMoving=true; } } } if(bMoving) { GetParent()->ScreenToClient(rect1); pWnd->MoveWindow(rect1,FALSE); lstRect.AddTail(rectBak); } } m_bOpen=FALSE; if(!g_bLockRedraw) GetParent()->InvalidateRect(GetTotalRect(lstRect)); GetParent()->SendMessage(WG_MES_CHILDSIZE); m_ctrlToolTip.UpdateTipText(m_sTipUnfold,this,1); GetClientRect(rect); m_ctrlToolTip.SetToolRect(this,1,rect); } void WGroupCtrl::UnFold() { CRect rectRedraw; BOOL bLimitRect=FALSE; if(m_pGroup!=NULL) { if(m_pGroup->m_nMaxExtent>0&&m_pGroup->m_nMaxOpenNum==1)//限定范围互斥 { GetWindowRect(rectRedraw); GetParent()->ScreenToClient(rectRedraw); for(m_pGroup->MoveToFirst();!m_pGroup->IsOut();m_pGroup->MoveToNext()) { if(m_pGroup->GetCurData()->IsOpened()) { CRect rect; m_pGroup->GetCurData()->GetWindowRect(rect); GetParent()->ScreenToClient(rect); rectRedraw=AddExtend(rectRedraw,rect); bLimitRect=TRUE; break; } } } XPushMemVar vTemp(g_bLockRedraw,bLimitRect);//阻止刷新 m_pGroup->OnBeforeUnfold(this); } CRect rect; GetWindowRect(rect); int nOffset=GetUnfoldExtent()-(IsVert()?rect.Height():rect.Width()); //移动后面窗口 CRect rectUnite=rect; GetParent()->ScreenToClient(rectUnite); DualList lstRect; lstRect.AddTail(rectUnite); for(CWnd*pWnd=GetParent()->GetWindow(GW_CHILD);pWnd!=NULL;pWnd=pWnd->GetNextWindow()) { if(pWnd==this) continue; CRect rect1; pWnd->GetWindowRect(rect1); bool bMoving=false; if(IsVert()) { if(rect1.top>rect.bottom)//下方 { if(rect1.left>=rect.left&&rect1.right<=rect.right)//正下方 { rect1.bottom+=nOffset; rect1.top+=nOffset; bMoving=true; } } } else { if(rect1.left>rect.right)//右方 { if(rect1.top>=rect.top&&rect1.bottom<=rect.bottom)//正右方 { rect1.right+=nOffset; rect1.left+=nOffset; bMoving=true; } } } //if(IsVert()) //{ // if(rect1.top>rect.bottom)//下方 // { // if(rect1.left<=rect.right&&rect1.right>=rect.left)//相关 // { // rect1.bottom+=nOffset; // rect1.top+=nOffset; // bMoving=true; // } // } //} //else //{ // if(rect1.left>rect.right)//右方 // { // if(rect1.top<=rect.bottom&&rect1.bottom>=rect.top)//相关 // { // rect1.right+=nOffset; // rect1.left+=nOffset; // bMoving=true; // } // } //} if(bMoving) { GetParent()->ScreenToClient(rect1); pWnd->MoveWindow(rect1,FALSE); lstRect.AddTail(rect1); } } //展开自身 if(IsVert()) rect.bottom=rect.top+m_nExtent; else rect.right=rect.left+m_nExtent; GetParent()->ScreenToClient(rect); MoveWindow(rect); //显示组内窗口 for(m_lstWinHandle.MoveToFirst(),m_lstWinRect.MoveToFirst();!m_lstWinHandle.IsOut();m_lstWinHandle.MoveToNext(),m_lstWinRect.MoveToNext()) { CWnd* pWnd=CWnd::FromHandle(m_lstWinHandle.GetCurData()); CRect rect=m_lstWinRect.GetCurData(); ClientToScreen(rect); GetParent()->ScreenToClient(rect); pWnd->MoveWindow(rect,FALSE); //pWnd->ShowWindow(SW_SHOW); } m_bOpen=TRUE; if(!bLimitRect) GetParent()->InvalidateRect(GetTotalRect(lstRect)); else GetParent()->InvalidateRect(rectRedraw); GetParent()->SendMessage(WG_MES_CHILDSIZE); m_ctrlToolTip.UpdateTipText(m_sTipFold,this,1); GetClientRect(rect); m_ctrlToolTip.SetToolRect(this,1,rect); } void WGroupCtrl::OnLButtonDown(UINT nFlags,CPoint point) { //if(GetParent()!=NULL) // GetParent()->SetFocus(); m_ctrlToolTip.Pop(); if(IsOpened()) Fold(); else UnFold(); } void WGroupCtrl::OnLButtonDblClk(UINT nFlags,CPoint point) { } BOOL WGroupCtrl::OnSetCursor(CWnd* /*pWnd*/, UINT /*nHitTest*/, UINT /*message*/) { if(g_hHandCursor==NULL) { CTemporaryResourceOverride vTemp; g_hHandCursor=AfxGetApp()->LoadCursor(IDC_HAND_CURSOR); } if (g_hHandCursor) { ::SetCursor(g_hHandCursor); return TRUE; } return FALSE; } void WGroupCtrl::OnMouseMove(UINT nFlags, CPoint point) { CStatic::OnMouseMove(nFlags,point); if (m_bOverControl) // Cursor currently over control { ClientToScreen(&point); if(OnNcHitTest(point)!=HTCLIENT) { m_bOverControl = FALSE; ReleaseCapture(); Invalidate(); } } else // Cursor has left control area { m_bOverControl = TRUE; SetCapture(); Invalidate(); } } void WGroupCtrl::PreSubclassWindow() { DWORD dwStyle = GetStyle(); #ifndef _WIN64 ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY); #else ::SetWindowLongPtr(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY); #endif SetFont(GetParent()->GetFont()); CStatic::PreSubclassWindow(); CString sTitle; GetWindowText(sTitle); m_sTipFold.Format(_T("点击这里折叠%s组"),(const TCHAR*)sTitle); m_sTipUnfold.Format(_T("点击这里展开%s组"),(const TCHAR*)sTitle); m_ctrlToolTip.Create(this); CRect rect; GetClientRect(rect); m_ctrlToolTip.AddTool(this,m_sTipFold,rect,1); m_ctrlToolTip.SetDelayTime(TTDT_RESHOW,0); } BOOL WGroupCtrl::PreTranslateMessage(MSG* pMsg) { m_ctrlToolTip.RelayEvent(pMsg); return CStatic::PreTranslateMessage(pMsg); } CRect WGroupCtrl::GetButtonRect() { CClientDC dc(this); // device context for painting dc.SelectObject(GetFont()); int fontHeight; TEXTMETRIC tm; dc.GetTextMetrics(&tm); fontHeight=tm.tmHeight; if(fontHeight%2==0) fontHeight+=1; if(IsVert()) return CRect(WG_BUTTON_OFFSET+1,0+1,WG_BUTTON_OFFSET+fontHeight-1,fontHeight-1); else return CRect(0+1,WG_BUTTON_OFFSET+1,fontHeight-1,WG_BUTTON_OFFSET-1+fontHeight); } #if ADS<17 UINT WGroupCtrl::OnNcHitTest(CPoint point) #else LRESULT WGroupCtrl::OnNcHitTest(CPoint point) #endif { if(!IsOpened()) { CRect rect; GetWindowRect(rect); if(rect.PtInRect(point)) return HTCLIENT; else return HTTRANSPARENT; } ScreenToClient(&point); CRect rectButton=GetButtonRect(); if(rectButton.PtInRect(point)) return HTCLIENT; else return HTTRANSPARENT; } void WGroupCtrl::OnPaint() { CPaintDC dc(this); // device context for painting CFont *pOldFont=dc.SelectObject(GetFont()); int fontHeight; TEXTMETRIC tm; dc.GetTextMetrics(&tm); fontHeight=tm.tmHeight; if(fontHeight%2==0) fontHeight+=1; CRect rect; GetClientRect(rect); CPen borderPen(PS_SOLID,1,RGB(170,190,200)); CPen* pOldPen=dc.SelectObject(&borderPen); if(IsVert()) rect.top+=fontHeight/2; else rect.left+=fontHeight/2; CBrush brush; brush.CreateStockObject(NULL_BRUSH); CBrush* pOldBrush=dc.SelectObject(&brush); if(IsOpened()) dc.RoundRect(rect,CPoint(4,4)); else { CRect rectClient; GetClientRect(rectClient); //dc.DrawFrameControl(rectClient,DFC_BUTTON,DFCS_BUTTONPUSH); //dc.Draw3dRect(rectClient,RGB(220,220,220),RGB(120,120,120)); dc.DrawEdge(rectClient, BDR_RAISEDOUTER, BF_RECT); } CPen buttonPen(PS_SOLID,1,RGB(0,0,250)); dc.SetTextColor(RGB(0,0,250)); dc.SetBkColor(GetSysColor(COLOR_3DFACE)); dc.SelectObject(&buttonPen); CString text; GetWindowText(text); CBrush brushButton; if(m_bOverControl) brushButton.CreateSolidBrush(RGB(255,255,0)); else brushButton.CreateSolidBrush(GetSysColor(COLOR_3DFACE)); dc.SelectObject(&brushButton); if(IsVert()) { CRect rectButton(WG_BUTTON_OFFSET+1,0+1,WG_BUTTON_OFFSET+fontHeight-1,fontHeight-1); if(IsNot(WG_ST_ICONBUTTON)) { dc.Rectangle(rectButton); dc.MoveTo(WG_BUTTON_OFFSET+3,rect.top); dc.LineTo(WG_BUTTON_OFFSET-3+fontHeight,rect.top); if(!IsOpened())//竖线 { dc.MoveTo(WG_BUTTON_OFFSET+fontHeight/2,0+3); dc.LineTo(WG_BUTTON_OFFSET+fontHeight/2,fontHeight-3); } } else { CTemporaryResourceOverride vtemp; DrawIconEx(dc.GetSafeHdc(),rectButton.left,rectButton.top,AfxGetApp()->LoadIcon(IsOpened()?IDI_GROUP_UP:IDI_GROUP_DOWN) ,rectButton.Width(),rectButton.Height(),NULL,NULL,DI_NORMAL); } dc.SetTextAlign(TA_LEFT|TA_TOP); dc.TextOut(WG_BUTTON_OFFSET+fontHeight+3,1,text); } else { CRect rectButton(0+1,WG_BUTTON_OFFSET+1,fontHeight-1,WG_BUTTON_OFFSET-1+fontHeight); if(IsNot(WG_ST_ICONBUTTON)) { dc.Rectangle(rectButton); dc.MoveTo(0+3,WG_BUTTON_OFFSET+fontHeight/2); dc.LineTo(fontHeight-3,WG_BUTTON_OFFSET+fontHeight/2); if(!IsOpened())//竖线 { dc.MoveTo(fontHeight/2,WG_BUTTON_OFFSET+3); dc.LineTo(fontHeight/2,WG_BUTTON_OFFSET-3+fontHeight); } } else { CTemporaryResourceOverride vtemp; DrawIconEx(dc.GetSafeHdc(),rectButton.left,rectButton.top,AfxGetApp()->LoadIcon(IsOpened()?IDI_GROUP_LEFT:IDI_GROUP_RIGHT) ,rectButton.Width(),rectButton.Height(),NULL,NULL,DI_NORMAL); } //下面是绘制旋转文字 //LOGFONT lg; //GetFont()->GetLogFont(&lg); //lg.lfEscapement=2700; //lg.lfOrientation=2700; //CFont font; //font.CreateFontIndirect(&lg); //dc.SelectObject(&font); //dc.SetTextAlign(TA_LEFT|TA_BOTTOM); //dc.TextOut(0,WG_BUTTON_OFFSET+fontHeight+3,text); DrawVertText(&dc,text,CPoint(1,WG_BUTTON_OFFSET+fontHeight+3)); } dc.SelectObject(pOldPen); dc.SelectObject(pOldBrush); dc.SelectObject(pOldFont); } //void WGroupCtrl::OnPaint() //{ // CPaintDC dc(this); // device context for painting // CFont *pOldFont=dc.SelectObject(GetFont()); // int fontHeight; // TEXTMETRIC tm; // dc.GetTextMetrics(&tm); // fontHeight=tm.tmHeight; // if(fontHeight%2==0) // fontHeight+=1; // // CRect rect; // GetClientRect(rect); // CPen borderPen(PS_SOLID,1,RGB(170,190,200)); // CPen* pOldPen=dc.SelectObject(&borderPen); // if(IsVert()) // rect.top+=fontHeight/2; // else // rect.left+=fontHeight/2; // // CBrush brush; // brush.CreateStockObject(NULL_BRUSH); // CBrush* pOldBrush=dc.SelectObject(&brush); // //if(IsOpened()) // dc.RoundRect(rect,CPoint(4,4)); // //else // { // CRect rectClient; // GetClientRect(rectClient); // //dc.Draw3dRect(rectClient,RGB(220,220,220),RGB(120,120,120)); // dc.DrawEdge(rectClient, BDR_RAISEDOUTER, BF_RECT); // } // // CPen buttonPen(PS_SOLID,1,RGB(0,0,250)); // dc.SetTextColor(RGB(0,0,250)); // dc.SetBkColor(GetSysColor(COLOR_3DFACE)); // dc.SelectObject(&buttonPen); // CString text; // GetWindowText(text); // CBrush brushButton; // if(m_bOverControl) // brushButton.CreateSolidBrush(RGB(255,255,0)); // else // brushButton.CreateSolidBrush(GetSysColor(COLOR_3DFACE)); // dc.SelectObject(&brushButton); // if(IsVert()) // { // CRect rectButton(WG_BUTTON_OFFSET+1,0+1,WG_BUTTON_OFFSET+fontHeight-1,fontHeight-1); // if(IsNot(WG_ST_ICONBUTTON)) // { // dc.Rectangle(rectButton); // dc.MoveTo(WG_BUTTON_OFFSET+3,rect.top); // dc.LineTo(WG_BUTTON_OFFSET-3+fontHeight,rect.top); // if(!IsOpened())//竖线 // { // dc.MoveTo(WG_BUTTON_OFFSET+fontHeight/2,0+3); // dc.LineTo(WG_BUTTON_OFFSET+fontHeight/2,fontHeight-3); // } // } // else // { // CTemporaryResourceOverride vtemp; // DrawIconEx(dc.GetSafeHdc(),rectButton.left,rectButton.top,AfxGetApp()->LoadIcon(IsOpened()?IDI_GROUP_UP:IDI_GROUP_DOWN) // ,rectButton.Width(),rectButton.Height(),NULL,NULL,DI_NORMAL); // } // // dc.SetTextAlign(TA_LEFT|TA_TOP); // dc.TextOut(WG_BUTTON_OFFSET+fontHeight+3,0,text); // } // else // { // CRect rectButton(0+1,WG_BUTTON_OFFSET+1,fontHeight-1,WG_BUTTON_OFFSET-1+fontHeight); // if(IsNot(WG_ST_ICONBUTTON)) // { // dc.Rectangle(rectButton); // dc.MoveTo(0+3,WG_BUTTON_OFFSET+fontHeight/2); // dc.LineTo(fontHeight-3,WG_BUTTON_OFFSET+fontHeight/2); // if(!IsOpened())//竖线 // { // dc.MoveTo(fontHeight/2,WG_BUTTON_OFFSET+3); // dc.LineTo(fontHeight/2,WG_BUTTON_OFFSET-3+fontHeight); // } // } // else // { // CTemporaryResourceOverride vtemp; // DrawIconEx(dc.GetSafeHdc(),rectButton.left,rectButton.top,AfxGetApp()->LoadIcon(IsOpened()?IDI_GROUP_LEFT:IDI_GROUP_RIGHT) // ,rectButton.Width(),rectButton.Height(),NULL,NULL,DI_NORMAL); // } // // //下面是绘制旋转文字 // //LOGFONT lg; // //GetFont()->GetLogFont(&lg); // //lg.lfEscapement=2700; // //lg.lfOrientation=2700; // //CFont font; // //font.CreateFontIndirect(&lg); // //dc.SelectObject(&font); // //dc.SetTextAlign(TA_LEFT|TA_BOTTOM); // //dc.TextOut(0,WG_BUTTON_OFFSET+fontHeight+3,text); // DrawVertText(&dc,text,CPoint(1,WG_BUTTON_OFFSET+fontHeight+3)); // } // // dc.SelectObject(pOldPen); // dc.SelectObject(pOldBrush); // dc.SelectObject(pOldFont); //} //////////////////////////////////////////////////////////////////////////////////////////// void WGroupCtrls::Append(WGroupCtrl*pCtrl) { AddTail(pCtrl); pCtrl->SetGroup(this); } void WGroupCtrls::SetMaxExtent(int size) { m_nMaxExtent=size; for(MoveToFirst();!IsOut();MoveToNext()) { if(GetCurData()->IsOpened()) { GetCurData()->Fold(); GetCurData()->UnFold(); break; } } } void WGroupCtrls::OnBeforeUnfold(WGroupCtrl*pCtrl) { extern BOOL g_bLockAutoSize; XPushMemVar vt(g_bLockAutoSize,TRUE); if(m_nMaxOpenNum>0)//关闭一个直到空出位置 { int count=0; for(MoveToFirst();!IsOut();MoveToNext()) if(GetCurData()->IsOpened()) count++; if(count>=m_nMaxOpenNum) { //自动折叠 for(MoveToLast();!IsOut()&&count>=m_nMaxOpenNum;MoveToPre()) if(GetCurData()->IsOpened()&&GetCurData()->IsNot(WG_ST_NOAUTOFOLD)) { GetCurData()->Fold(); count--; } if(count>=m_nMaxOpenNum)//强制折叠 { for(MoveToLast();!IsOut()&&count>=m_nMaxOpenNum;MoveToPre()) if(GetCurData()->IsOpened()) { GetCurData()->Fold(); count--; } } } } if(m_nMaxExtent<1||m_nMaxOpenNum!=1)//没有范围限制 return; //范围限制后,自动计算尺寸 DualList lstRect; for(MoveToFirst();!IsOut();MoveToNext()) { CRect rect; GetCurData()->GetWindowRect(rect); lstRect.AddTail(rect); } CRect rectNowTotal=GetTotalRect(lstRect); int sizeNowTotal=pCtrl->IsVert()?rectNowTotal.Height():rectNowTotal.Width(); CRect rectNow; pCtrl->GetWindowRect(rectNow); int sizeNow=pCtrl->IsVert()?rectNow.Height():rectNow.Width(); pCtrl->SetUnfoldExtent(sizeNow+m_nMaxExtent-sizeNowTotal); }