void CZhfPalette::OnSize(UINT nType, int cx, int cy) { CAdUiPalette::OnSize(nType, cx, cy); // TODO: 在此添加消息处理程序代码 if (cx<m_iCtrlWidth+m_iMarginX||cy<m_iCtrlHeight+m_iMarginY) { return ; } int iCtrlNum = m_pArrayPreviewCtrl.GetCount() ; int iCol = cx/(m_iCtrlWidth+m_iMarginX) ; int iRow = iCtrlNum/iCol + (iCtrlNum%iCol==0?0:1); SCROLLINFO si; si.cbSize = sizeof(si); si.fMask = SIF_RANGE | SIF_PAGE; si.nMin = 0; si.nMax = iRow-1 ; si.nPage = cy/(m_iCtrlHeight+m_iMarginY) ; SetScrollInfo(SB_VERT,&si,TRUE); ScrollWindow(0,0); m_iOldPosY = 0; Invalidate(TRUE); if (m_pArrayPreviewCtrl.GetCount()>0&&cx>(m_iCtrlWidth+m_iMarginX)) { TRACE(_T("\ncx:%d, cy:%d"),cx, cy) ; ResizeCtrl(cx, cy) ; } }
void CRemoteFileDialog::PostCreate() { if (m_toolbar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE)) { UINT nStyle = m_toolbar.GetBarStyle(); nStyle &= ~(CCS_NORESIZE | CCS_NOPARENTALIGN | CBRS_BORDER_ANY); nStyle |= (CBRS_SIZE_FIXED | CBRS_TOOLTIPS | CBRS_FLYBY); m_toolbar.SetBarStyle(nStyle); m_toolbar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS); int iImage = m_toolbar.GetToolBarCtrl().SendMessage(TB_LOADIMAGES, IDB_VIEW_SMALL_COLOR, (LPARAM)HINST_COMMCTRL); // add 'up folder' item TBBUTTON tbbUp = { iImage + VIEW_PARENTFOLDER, ID_UPONELEVEL, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, 0 }; m_toolbar.GetToolBarCtrl().InsertButton(0, &tbbUp); // add 'view' item with drop menu TBBUTTON tbbView = { iImage + VIEW_LIST, ID_VIEWMENU, TBSTATE_ENABLED, TBSTYLE_BUTTON | TBSTYLE_DROPDOWN, 0, 0 }; m_toolbar.GetToolBarCtrl().InsertButton(1, &tbbView); // move to topright corner CDlgUnits dlu(*this); CRect rToolbar, rButton; GetClientRect(rToolbar); m_toolbar.GetItemRect(1, rButton); rToolbar.top += dlu.ToPixelsY(4); rToolbar.right -= dlu.ToPixelsX(7); rToolbar.left = rToolbar.right - rButton.right; rToolbar.bottom = rToolbar.top + rButton.Height(); m_toolbar.MoveWindow(rToolbar); CRect rCtrl = OffsetCtrl(IDC_CURRENTFOLDER); ResizeCtrl(IDC_CURRENTFOLDER, rToolbar.left - rCtrl.right - 4, 0); } // restore size DWORD dwSize = AfxGetApp()->GetProfileInt(_T("RemoteSettings"), _T("LastSize"), -1); if (dwSize != -1) { int nWidth = LOWORD(dwSize); int nHeight = HIWORD(dwSize); // centre on current position CRect rWindow; GetWindowRect(rWindow); rWindow.InflateRect((nWidth - rWindow.Width()) / 2, (nHeight - rWindow.Height()) / 2); MoveWindow(rWindow); } // restore last view int nView = AfxGetApp()->GetProfileInt(_T("RemoteSettings"), _T("LastView"), LVS_LIST); OnChangeView(VIEWIDS[nView]); // init resize icon GetDlgItem(IDC_GRIPPER)->ModifyStyle(0, SBS_SIZEGRIP | SBS_SIZEBOXTOPLEFTALIGN); // and fill the file list SetCurrentFolder(m_sCurFolder); }