void dlu(int i) /* down-left-up */ { if (i == 0) return; ldr(i - 1); draw_rel( 0, -h); dlu(i - 1); draw_rel(-h, 0); dlu(i - 1); draw_rel( 0, h); rul(i - 1); }
HWND CRuntimeDlg::CreateControl(LPCTSTR szClass, LPCTSTR szCaption, DWORD dwStyle, DWORD dwExStyle, int x, int y, int cx, int cy, UINT nID, BOOL bDLU, UINT nIconID) { if (bDLU) { CDlgUnits dlu(*this); dlu.ToPixels(x, y); dlu.ToPixels(cx, cy); } // override caption CString sCaption = OverrideItemText(nID); if (sCaption.IsEmpty()) sCaption = szCaption; // validate the topleft position against the borders x = max(x, m_rBorders.left); y = max(y, m_rBorders.top); // make reasonably sure control is child dwStyle |= WS_CHILD; dwStyle &= ~WS_POPUP; // we don't need to be notified by our own children dwExStyle |= WS_EX_NOPARENTNOTIFY; // if its a richedit then make sure richedit dll is initialized HWND hwnd = NULL; if (CWinClasses::IsRichEditControl(szClass)) hwnd = CreateRichEdit(szClass, sCaption, dwStyle, dwExStyle, x, y, cx, cy, *this, nID); else hwnd = ::CreateWindowEx(dwExStyle, szClass, sCaption, dwStyle, x, y, cx, cy, *this, (HMENU)nID, NULL, NULL); if (hwnd) { HFONT hFont = (HFONT)SendMessage(WM_GETFONT); // gets the dialog's font if (!hFont) hFont = (HFONT)::GetStockObject(DEFAULT_GUI_FONT); ::SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, 0); if (nIconID && _tcsicmp(szClass, _T("static")) == 0) { HICON hIcon = AfxGetApp()->LoadIcon(nIconID); if (hIcon) ::SendMessage(hwnd, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); } else if (!sCaption.IsEmpty()) ::SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)sCaption); } else TRACE(_T("CreateWindowEx(%s) failed. GetLastError returned %08X\n"), szClass, GetLastError()); return hwnd; }
void rul(int i) /* right-up-left */ { if (i == 0) return; urd(i - 1); draw_rel( h, 0); rul(i - 1); draw_rel( 0, h); rul(i - 1); draw_rel(-h, 0); dlu(i - 1); }
void ldr(int i) /* left-down-right */ { if (i == 0) return; dlu(i - 1); draw_rel(-h, 0); ldr(i - 1); draw_rel( 0, -h); ldr(i - 1); draw_rel( h, 0); urd(i - 1); }
void CRemoteFileDialog::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { CRuntimeDlg::OnGetMinMaxInfo(lpMMI); CDlgUnits dlu(*this); lpMMI->ptMinTrackSize.x = dlu.ToPixelsX(294); lpMMI->ptMinTrackSize.y = dlu.ToPixelsY(200); }
void CRemoteFileDialog::OnSize(UINT nType, int cx, int cy) { CRuntimeDlg::OnSize(nType, cx, cy); if (!GetDlgItem(IDC_CURRENTFOLDER)) { return; // not ready } // we use the cancel button as our placeholder CRect rCancel = OffsetCtrl(IDCANCEL); CDlgUnits dlu(*this); int nXOffset = cx - rCancel.right - dlu.ToPixelsX(7); int nYOffset = cy - rCancel.bottom - dlu.ToPixelsY(7); CDeferWndMove dwm(10); dwm.ResizeCtrl(this, IDC_CURRENTFOLDER, nXOffset, 0); dwm.ResizeCtrl(this, IDC_FILELIST, nXOffset, nYOffset); if (m_toolbar.GetSafeHwnd()) { CRect rToolbar = OffsetCtrl(AFX_IDW_TOOLBAR); rToolbar.OffsetRect(nXOffset, 0); dwm.MoveWindow(&m_toolbar, rToolbar); } CRect rCtrl = OffsetCtrl(IDC_FILETYPES); rCtrl.right += nXOffset; rCtrl.OffsetRect(0, nYOffset); dwm.MoveWindow(GetDlgItem(IDC_FILETYPES), rCtrl); rCtrl = OffsetCtrl(IDC_FILENAME); rCtrl.right += nXOffset; rCtrl.OffsetRect(0, nYOffset); dwm.MoveWindow(GetDlgItem(IDC_FILENAME), rCtrl); dwm.OffsetCtrl(this, IDC_FILENAMELABEL, 0, nYOffset); dwm.OffsetCtrl(this, IDC_FILETYPESLABEL, 0, nYOffset); dwm.OffsetCtrl(this, IDOK, nXOffset, nYOffset); dwm.OffsetCtrl(this, IDCANCEL, nXOffset, nYOffset); CRect rGrip = OffsetCtrl(IDC_GRIPPER); rGrip.OffsetRect(cx - rGrip.right, cy - rGrip.bottom); dwm.MoveWindow(GetDlgItem(IDC_GRIPPER), rGrip); }
void CRuntimeDlg::SetBordersDLU(int nLeft, int nTop, int nRight, int nBottom) { if (GetSafeHwnd()) { CDlgUnits dlu(*this); dlu.ToPixels(nLeft, nTop); dlu.ToPixels(nRight, nBottom); SetBorders(nLeft, nTop, nRight, nBottom); } else { m_rBorders.SetRectEmpty(); m_rBordersDLU.SetRect(max(0, nLeft), max(0, nTop), max(0, nRight), max(0, nBottom)); } }
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); }
int CTDLFilterBar::ReposControls(int nWidth, BOOL bCalcOnly) { CDeferWndMove dwm(bCalcOnly ? 0 : NUMFILTERCTRLS + 1); if (nWidth <= 0) { CRect rClient; GetClientRect(rClient); nWidth = rClient.Width(); } // Note: All calculations are performed in DLU until just before the move // is performed. This ensures that we minimize the risk of rounding errors. CDlgUnits dlu(*this); int nXPosDLU = 0, nYPosDLU = 0; int nWidthDLU = dlu.FromPixelsX(nWidth), nCtrlHeightDLU = CTRLHEIGHT; for (int nCtrl = 0; nCtrl < NUMFILTERCTRLS; nCtrl++) { CRect rCtrl, rCtrlDLU; const FILTERCTRL& fc = FILTERCTRLS[nCtrl]; // display this control only if the corresponding column // is also showing BOOL bWantCtrl = WantShowFilter(fc.nType); if (bWantCtrl) { // if we're at the start of the line then just move ctrls // else we must check whether there's enough space to fit if (nXPosDLU > 0) // we're not the first { // do we fit? if ((nXPosDLU + CTRLLEN) > nWidthDLU) // no { // move to next line nXPosDLU = 0; nYPosDLU += CTRLYSPACING + (2 * nCtrlHeightDLU); } } // move label rCtrlDLU.left = nXPosDLU; rCtrlDLU.right = nXPosDLU + CTRLLEN; rCtrlDLU.top = nYPosDLU; rCtrlDLU.bottom = nYPosDLU + nCtrlHeightDLU; rCtrl = rCtrlDLU; dlu.ToPixels(rCtrl); if (fc.nIDLabel && !bCalcOnly) dwm.MoveWindow(GetDlgItem(fc.nIDLabel), rCtrl); // update YPos for the ctrl rCtrlDLU.OffsetRect(0, nCtrlHeightDLU); // move ctrl rCtrl = rCtrlDLU; dlu.ToPixels(rCtrl); if (!bCalcOnly) dwm.MoveWindow(GetDlgItem(fc.nIDCtrl), rCtrl); // update XPos for the control nXPosDLU = rCtrlDLU.right + CTRLXSPACING; } // show/hide and enable as appropriate if (!bCalcOnly) { BOOL bSelFilter = (m_filter.nShow == FS_SELECTED); BOOL bEnable = bWantCtrl; // special cases if (bEnable && fc.nIDCtrl != IDC_FILTERCOMBO) { if (bSelFilter && fc.nIDCtrl != IDC_OPTIONFILTERCOMBO) bEnable = FALSE; else if (m_bCustomFilter) bEnable = FALSE; } if (fc.nIDLabel) { GetDlgItem(fc.nIDLabel)->ShowWindow(bWantCtrl ? SW_SHOW : SW_HIDE); // note the first ctrl is always enabled even for custom filter GetDlgItem(fc.nIDLabel)->EnableWindow(bEnable); } GetDlgItem(fc.nIDCtrl)->ShowWindow(bWantCtrl ? SW_SHOW : SW_HIDE); GetDlgItem(fc.nIDCtrl)->EnableWindow(bEnable); } } // update bottom of filter bar nYPosDLU += (2 * nCtrlHeightDLU) + 2; return dlu.ToPixelsY(nYPosDLU); }