void CUserListDlg::OnSize( UINT nType, int cx, int cy ) { CDialog::OnSize( nType, cx, cy ); CListBox* userList = (CListBox*)GetDlgItem( IDC_USERLIST ); CButton* newButton = (CButton*)GetDlgItem( IDC_NEWUSERBUTTON ); CButton* deleteButton = (CButton*)GetDlgItem( IDC_DELETEUSERBUTTON ); if ( userList && newButton && deleteButton ) { CRect client; GetClientRect( client ); CRect button; newButton->CButton::GetWindowRect( button ); userList->MoveWindow( 0, 0, client.Width(), client.Height()-button.Height() ); newButton->MoveWindow( 0, client.Height()-button.Height(), client.Width()/2, button.Height() ); deleteButton->MoveWindow( client.Width()/2, client.Height()-button.Height(), client.Width()/2, button.Height() ); } }
void CMyGroupBox::AdjustRadio() { CRect rcTmp; GetClientRect(rcTmp); int nWith = rcTmp.Width(); for (int i = 0; i < GetRadioCount(); i++) { CButton* pBtn = m_RadioList.GetAt(i); pBtn->MoveWindow(10, 20 + i * m_nRadioHeight, nWith - 10 * 2, m_nRadioHeight); } }
void CRichListCtrl::DrawItem(CDC* pDC, int nItem, CRect &rcItem) { if (nItem < 0 || nItem >= (int)m_vctItem.size()) { return; } bool bSelected = false; if (GetItemState(nItem, LVIS_SELECTED)) { bSelected = true; } bool bFocus = false; CWnd *pWndFocus = GetFocus(); if (IsChild(pWndFocus) || pWndFocus == this) { bFocus = true; } int pos = GetScrollPos(SB_HORZ); int nColumnCount = GetHeaderCtrl()->GetItemCount(); CRect rcSubItem; for (int j = 0; j < nColumnCount; ++j) { GetHeaderCtrl()->GetItemRect(j, &rcSubItem); rcSubItem.top = rcItem.top; rcSubItem.bottom = rcItem.bottom; rcSubItem.OffsetRect(-pos, 0); if(rcSubItem.right < rcItem.left || rcSubItem.left > rcItem.right) { continue; } map<int, ListSubItem*>::iterator it = m_vctItem[nItem].find(j); if (it == m_vctItem[nItem].end() || it->second->itemType == CTRL_STATIC) { DrawSubItem(pDC, nItem, j, rcSubItem, bSelected, bFocus); } else if (it->second->itemType == CTRL_BUTTON) { CButton *pButton = (CButton*)(it->second->pItem); if (pButton != NULL) { pButton->ShowWindow(SW_SHOW); pButton->MoveWindow(rcSubItem); } } } }
void CWelcomeWnd::OnPaint() { CPaintDC dc(this); // device context for painting // get our own DC instead, with no restrictions CDC* pDC = GetDC(); // realize the palette CPalette* pOldPalette = pDC->SelectPalette(m_bitmap.GetPalette(), FALSE); pDC->RealizePalette(); // And draw the bitmap BITMAP bmInfo; if (m_bitmap.m_hObject == NULL) return; m_bitmap.GetObject(sizeof(BITMAP),&bmInfo); CDC newDC; newDC.CreateCompatibleDC(pDC); CBitmap* pOldBitmap = newDC.SelectObject(&m_bitmap); pDC->BitBlt(0,0,bmInfo.bmWidth,bmInfo.bmHeight,&newDC,0,0,SRCCOPY); // (void)newDC.SelectObject(pOldBitmap); newDC.DeleteDC(); pDC->SelectPalette(pOldPalette, FALSE); ReleaseDC(pDC); // draw the 'OK' button CRect winRect, rect; GetClientRect(&winRect); CButton* pBtn = (CButton*) GetDlgItem(IDOK); pBtn->GetWindowRect(&rect); ScreenToClient(&rect); int nWidth = rect.Width(); int nHeight = rect.Height(); rect.bottom = winRect.bottom - 24; rect.top = rect.bottom - nHeight; rect.left = (winRect.right - nWidth) / 2; rect.right = rect.left + nWidth; pBtn->MoveWindow(&rect); pBtn->ShowWindow(SW_SHOW); }
void CXTPColorDialog::CalculateRects() { CRect rcBtnOK; CRect rcBtnCancel; CRect rcTabCtrl; CRect rcItem; // get the tab control size. CTabCtrl* pTabCtrl = GetTabControl(); pTabCtrl->GetWindowRect(&rcTabCtrl); ScreenToClient(&rcTabCtrl); // get the size of the first tab item. pTabCtrl->GetItemRect(0, &rcItem); // get the OK button size. CButton* pBtnOK = (CButton*)GetDlgItem(IDOK); pBtnOK->GetWindowRect(&rcBtnOK); ScreenToClient(&rcBtnOK); // get the Cancel button size. CButton* pBtnCancel = (CButton*)GetDlgItem(IDCANCEL); pBtnCancel->GetWindowRect(&rcBtnCancel); ScreenToClient(&rcBtnCancel); rcBtnCancel.OffsetRect(-15, 0); // resize the tab control rcTabCtrl.right = rcBtnCancel.left - 5; rcTabCtrl.bottom = rcBtnCancel.top - 15; pTabCtrl->MoveWindow(&rcTabCtrl); // reposition the OK button. rcBtnOK = rcBtnCancel; rcBtnOK.top = rcTabCtrl.top + rcItem.Height() + 1; rcBtnOK.bottom = rcBtnOK.top + rcBtnCancel.Height(); pBtnOK->MoveWindow(&rcBtnOK); // reposition the Cancel button. rcBtnCancel = rcBtnOK; rcBtnCancel.top = rcBtnOK.bottom + 5; rcBtnCancel.bottom = rcBtnCancel.top + rcBtnOK.Height(); pBtnCancel->MoveWindow(&rcBtnCancel); // reposition the hex display if (::IsWindow(m_wndHexEdit.m_hWnd)) { CRect rcWnd; rcWnd = rcBtnCancel; rcWnd.top = rcBtnCancel.bottom + 5; rcWnd.bottom = rcWnd.top + 18; m_wndHexEdit.MoveWindow(&rcWnd); } // reposition the eye dropper. if (::IsWindow(m_wndEyeDropper.m_hWnd)) { CRect rcWnd; m_wndEyeDropper.GetWindowRect(&rcWnd); CSize size = rcWnd.Size(); rcWnd.right = rcBtnOK.right; rcWnd.left = rcBtnOK.right - size.cx; rcWnd.bottom = rcTabCtrl.bottom; rcWnd.top = rcTabCtrl.bottom - size.cy; m_wndEyeDropper.MoveWindow(&rcWnd); } // resize the property sheet. CXTPWindowRect rcWindow(this); ClientToScreen(&rcTabCtrl); rcWindow.bottom = rcTabCtrl.bottom + 10; rcWindow.right -= 15; MoveWindow(&rcWindow); }
/* This function update the window layout, the order of statement is significant. //*/ void CDlg3RGSegment::UpdateLayout( int cx, int cy ) { // Compute layout for the window and the image displaying region CStatic* ctrlStatic = NULL; CButton* ctrlButton = NULL; CComboBox* ctrlCombobox = NULL; CRect clientRect; CRect contrlRect; CRect infoRect; GetClientRect(&clientRect); ////////////////////////////////////////////////////////////////////////// // Compute the preprocessing group contrlRect.left = clientRect.left + SV_3DRG_SPACING; contrlRect.bottom = clientRect.bottom - SV_3DRG_SPACING; contrlRect.top = clientRect.bottom - SV_3DRG_GRP_HEIGHT; contrlRect.right = contrlRect.left + SV_3DRG_GRP_WIDTH; ctrlStatic = (CStatic*)GetDlgItem(IDC_3DRG_GRAYGRP); ctrlStatic->MoveWindow(&contrlRect, FALSE); // Preprocessing check box contrlRect.left += SV_3DRG_SPACING; contrlRect.top += SV_3DRG_SPACING * 2; contrlRect.right -= SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; m_chkPreproc.MoveWindow(&contrlRect, FALSE); // Brightness label contrlRect.top = contrlRect.bottom + SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; ctrlStatic = (CStatic*)GetDlgItem(IDC_LBL_BRIGHT); ctrlStatic->MoveWindow(&contrlRect, FALSE); //Brightness slider contrlRect.top = contrlRect.bottom + SV_3DRG_SMALL_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_SMALLSLIDERHEIGHT; contrlRect.right = contrlRect.left + SV_3DRG_CHARWIDTH; ctrlStatic =(CStatic*)GetDlgItem(IDC_BR_100); ctrlStatic->MoveWindow(&contrlRect, FALSE); contrlRect.left = contrlRect.right + SV_3DRG_SMALL_SPACING; contrlRect.right = contrlRect.left + SV_3DRG_SMALLSLIDERWIDTH; m_sldBright.MoveWindow(&contrlRect, FALSE); contrlRect.left = contrlRect.right + SV_3DRG_SMALL_SPACING; contrlRect.right = contrlRect.left + SV_3DRG_CHARWIDTH; ctrlStatic =(CStatic*)GetDlgItem(IDC_BR_M100); ctrlStatic->MoveWindow(&contrlRect, FALSE); // Contrast label contrlRect.top = contrlRect.bottom + SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; contrlRect.left = clientRect.left + SV_3DRG_SPACING *2; contrlRect.right = clientRect.left + SV_3DRG_SMALLSLIDERWIDTH; ctrlStatic = (CStatic*)GetDlgItem(IDC_LBL_CONTRAST); ctrlStatic->MoveWindow(&contrlRect, FALSE); // Contrast slider contrlRect.top = contrlRect.bottom + SV_3DRG_SMALL_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_SMALLSLIDERHEIGHT; contrlRect.right = contrlRect.left + SV_3DRG_CHARWIDTH; ctrlStatic = (CStatic*)GetDlgItem(IDC_CS_100); ctrlStatic->MoveWindow(&contrlRect, FALSE); contrlRect.left = contrlRect.right + SV_3DRG_SMALL_SPACING; contrlRect.right = contrlRect.left + SV_3DRG_SMALLSLIDERWIDTH; m_sldContrast.MoveWindow(&contrlRect, FALSE); contrlRect.left = contrlRect.right + SV_3DRG_SMALL_SPACING; contrlRect.right = contrlRect.left + SV_3DRG_CHARWIDTH; ctrlStatic =(CStatic*)GetDlgItem(IDC_CS_M100); ctrlStatic->MoveWindow(&contrlRect, FALSE); ////////////////////////////////////////////////////////////////////////// // Compute the region growing setting contrlRect.left = clientRect.left + SV_3DRG_SPACING*1.5 + SV_3DRG_GRP_WIDTH; contrlRect.bottom = clientRect.bottom - SV_3DRG_SPACING; contrlRect.top = clientRect.bottom - SV_3DRG_GRP_HEIGHT; contrlRect.right = contrlRect.left + SV_3DRG_GRP_WIDTH; ctrlStatic = (CStatic*)GetDlgItem(IDC_3DRG_SETTINGGRP); ctrlStatic->MoveWindow(&contrlRect, FALSE); // Use default check box contrlRect.left += SV_3DRG_SPACING; contrlRect.top += SV_3DRG_SPACING * 2; contrlRect.right -= SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; m_chkDefaultThres.MoveWindow(&contrlRect, FALSE); // Threshold slider label contrlRect.top = contrlRect.bottom + SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; ctrlStatic = (CStatic*)GetDlgItem(IDC_LBL_THRES); ctrlStatic->MoveWindow(&contrlRect, FALSE); // Threshold slider contrlRect.top = contrlRect.bottom + SV_3DRG_SMALL_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_SMALLSLIDERHEIGHT; contrlRect.right = contrlRect.left + SV_3DRG_CHARWIDTH*2; ctrlStatic = (CStatic*)GetDlgItem(IDC_TH_MIN); ctrlStatic->MoveWindow(&contrlRect, FALSE); // Slider threshold contrlRect.left = contrlRect.right + SV_3DRG_SMALL_SPACING; contrlRect.right = contrlRect.left + SV_3DRG_SMALLSLIDERWIDTH - 2*SV_3DRG_CHARWIDTH; m_sldThreshold.MoveWindow(&contrlRect, FALSE); m_rThres = contrlRect; // Label current threshold value m_sldThreshold.GetThumbRect(&infoRect); infoRect += contrlRect.TopLeft(); infoRect.top += SV_3DRG_SMALLSLIDERHEIGHT; infoRect.bottom += SV_3DRG_SMALLSLIDERHEIGHT; infoRect.right += SV_3DRG_CHARWIDTH *3; ctrlStatic =(CStatic*)GetDlgItem(IDC_TH_CUR); ctrlStatic->MoveWindow(&infoRect, FALSE); CString str; str.Format(_T("%d"), m_sldThreshold.GetPos()); ctrlStatic->SetWindowText(str); // Label max threshold contrlRect.left = contrlRect.right + SV_3DRG_SMALL_SPACING; contrlRect.right = contrlRect.left + SV_3DRG_CHARWIDTH *2; ctrlStatic =(CStatic*)GetDlgItem(IDC_TH_MAX); ctrlStatic->MoveWindow(&contrlRect, FALSE); // Label start slice contrlRect = m_rThres; contrlRect.left -= (SV_3DRG_CHARWIDTH*2 + SV_3DRG_SMALL_SPACING); contrlRect.top += (1.5*SV_3DRG_SMALLSLIDERHEIGHT + SV_3DRG_SPACING); contrlRect.right = contrlRect.left + SV_3DRG_CHARWIDTH*3; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; ctrlStatic = (CStatic*) GetDlgItem(IDC_3DRG_LBLSTART); ctrlStatic->MoveWindow(contrlRect); // Textbox start slice contrlRect.left = contrlRect.right + SV_3DRG_SMALL_SPACING; contrlRect.right = contrlRect.left + SV_3DRG_TEXTBOXWIDTH; CEdit* ctrlEdit = (CEdit*) GetDlgItem(IDC_3DRG_STARSLICE); ctrlEdit->MoveWindow(contrlRect); // Label end slice contrlRect.left = contrlRect.right + SV_3DRG_SPACING; contrlRect.right = contrlRect.left + SV_3DRG_CHARWIDTH * 3; ctrlStatic = (CStatic*)GetDlgItem(IDC_3DRG_LBLEND); ctrlStatic->MoveWindow(contrlRect); // textbox end slice contrlRect.left = contrlRect.right + SV_3DRG_SMALL_SPACING; contrlRect.right = contrlRect.left + SV_3DRG_TEXTBOXWIDTH; ctrlEdit = (CEdit*) GetDlgItem(IDC_3DRG_ENDSLICE); ctrlEdit->MoveWindow(contrlRect); // Boundary threshold label contrlRect.left = m_rThres.left - (SV_3DRG_CHARWIDTH*2 + SV_3DRG_SMALL_SPACING); contrlRect.top = contrlRect.bottom + SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; contrlRect.right = contrlRect.left + SV_3DRG_CHARWIDTH*9; ctrlStatic = (CStatic*)GetDlgItem(IDC_3DRG_BTHRES); ctrlStatic->MoveWindow(contrlRect); // // Threshold slider contrlRect.top = contrlRect.bottom + SV_3DRG_SMALL_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_SMALLSLIDERHEIGHT; contrlRect.right = contrlRect.left + SV_3DRG_CHARWIDTH*2; ctrlStatic = (CStatic*)GetDlgItem(IDC_TH_MINBTHRES); ctrlStatic->MoveWindow(&contrlRect, FALSE); // Slider boundary threshold contrlRect.left = contrlRect.right + SV_3DRG_SMALL_SPACING; contrlRect.right = contrlRect.left + SV_3DRG_SMALLSLIDERWIDTH - 2*SV_3DRG_CHARWIDTH; m_sldBoundThres.MoveWindow(&contrlRect, FALSE); m_rBthres = contrlRect; // Label current boundary threshold value m_sldBoundThres.GetThumbRect(&infoRect); infoRect += contrlRect.TopLeft(); infoRect.top += SV_3DRG_SMALLSLIDERHEIGHT; infoRect.bottom += SV_3DRG_SMALLSLIDERHEIGHT; infoRect.right += SV_3DRG_CHARWIDTH *3; ctrlStatic =(CStatic*)GetDlgItem(IDC_LBL_CURBTHRE); ctrlStatic->MoveWindow(&infoRect, FALSE); str.Format(_T("%d"), m_sldBoundThres.GetPos()); ctrlStatic->SetWindowText(str); // Label max threshold contrlRect.left = contrlRect.right + SV_3DRG_SMALL_SPACING; contrlRect.right = contrlRect.left + SV_3DRG_CHARWIDTH *2; ctrlStatic =(CStatic*)GetDlgItem(IDC_TH_MAXBTHRES); ctrlStatic->MoveWindow(&contrlRect, FALSE); ////////////////////////////////////////////////////////////////////////// // Compute the Operation mode contrlRect.left = clientRect.left + SV_3DRG_SPACING*2 + SV_3DRG_GRP_WIDTH *2; contrlRect.bottom = clientRect.bottom - SV_3DRG_SPACING; contrlRect.top = clientRect.bottom - SV_3DRG_GRP_HEIGHT; contrlRect.right = contrlRect.left + SV_3DRG_GRP_WIDTH; ctrlStatic = (CStatic*)GetDlgItem(IDC_3DRG_OPPGRP); ctrlStatic->MoveWindow(&contrlRect, FALSE); // Cutting mode radio contrlRect.left += SV_3DRG_SPACING; contrlRect.top += SV_3DRG_SPACING * 2; contrlRect.right -= SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; ctrlButton = (CButton*)GetDlgItem(IDC_3DRG_RAD_CUT); ctrlButton->MoveWindow(&contrlRect, FALSE); // Segmentation mode radio contrlRect.top = contrlRect.bottom + SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; ctrlButton = (CButton*)GetDlgItem(IDC_3DRG_RAD_SEG); ctrlButton->MoveWindow(&contrlRect, FALSE); // Cutting method combobox label contrlRect.top = contrlRect.bottom + SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; ctrlStatic = (CStatic*)GetDlgItem(IDC_3DRG_LBL_CUTMED); ctrlStatic->MoveWindow(&contrlRect, FALSE); // Cutting method combobox contrlRect.top = contrlRect.bottom + SV_3DRG_SPACING/2; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; ctrlCombobox = (CComboBox*)GetDlgItem(IDC_3DRG_CB_CUTMODE); ctrlCombobox->MoveWindow(&contrlRect, FALSE); // Boundary detection check box contrlRect.top = contrlRect.bottom + SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_TEXTHEIGHT; ctrlButton = (CButton*) GetDlgItem(IDC_3DRG_CHK_BOUND); ctrlButton->MoveWindow(&contrlRect, FALSE); // Segment start button contrlRect.top = contrlRect.bottom + SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_BUTTON_HEIGHT; ctrlButton = (CButton*)GetDlgItem(IDC_3DRG_START); ctrlButton->MoveWindow(&contrlRect, FALSE); ////////////////////////////////////////////////////////////////////////// // Compute the button set // Close button contrlRect.right = clientRect.right - SV_3DRG_SPACING; contrlRect.left = contrlRect.right - SV_3DRG_BUTTON_WIDTH; contrlRect.bottom = clientRect.bottom - SV_3DRG_SPACING; contrlRect.top = contrlRect.bottom - SV_3DRG_BUTTON_HEIGHT; ctrlButton = (CButton*)GetDlgItem(IDCANCEL); ctrlButton->MoveWindow(&contrlRect, FALSE); // Save volume button contrlRect.bottom = contrlRect.top - SV_3DRG_SPACING*2; contrlRect.top = contrlRect.bottom - SV_3DRG_BUTTON_HEIGHT; ctrlButton = (CButton*)GetDlgItem(IDC_3DRG_CMD_SAVEVOL); ctrlButton->MoveWindow(&contrlRect, FALSE); // Save all slice button contrlRect.bottom = contrlRect.top - SV_3DRG_SPACING/2; contrlRect.top = contrlRect.bottom - SV_3DRG_BUTTON_HEIGHT; ctrlButton = (CButton*)GetDlgItem(IDC_3DRG_CMD_SAVEALL); ctrlButton->MoveWindow(&contrlRect, FALSE); // Save a slice button contrlRect.bottom = contrlRect.top - SV_3DRG_SPACING/2; contrlRect.top = contrlRect.bottom - SV_3DRG_BUTTON_HEIGHT; ctrlButton = (CButton*)GetDlgItem(IDC_3DRG_CMD_SAVESINGLE); ctrlButton->MoveWindow(&contrlRect, FALSE); //Compute the image output size int nHeight = clientRect.Height() - (5*SV_3DRG_SPACING + SV_3DRG_GRP_HEIGHT + SV_3DRG_LARGESLIDERHEIGHT); int nWidth = (clientRect.Width() - 3*SV_3DRG_SPACING) /2; int nSize = min(nHeight, nWidth); m_OrgRegion.left = clientRect.left + SV_3DRG_SPACING; m_OrgRegion.top = clientRect.top + SV_3DRG_SPACING; m_OrgRegion.right = m_OrgRegion.left + nSize; m_OrgRegion.bottom = m_OrgRegion.top + nSize; m_ResRegion = m_OrgRegion; m_ResRegion.OffsetRect(nSize + SV_3DRG_SPACING, 0); ctrlStatic = (CStatic*)GetDlgItem(IDC_3DRG_ORGFRAME); ctrlStatic->MoveWindow(&m_OrgRegion, FALSE); ctrlStatic = (CStatic*)GetDlgItem(IDC_3DRG_RESFRAME); ctrlStatic->MoveWindow(&m_ResRegion, FALSE); contrlRect.left = m_OrgRegion.left; contrlRect.right = m_ResRegion.right; contrlRect.top = m_OrgRegion.bottom + SV_3DRG_SPACING; contrlRect.bottom = contrlRect.top + SV_3DRG_LARGESLIDERHEIGHT; m_sldSliceNo.MoveWindow(&contrlRect, FALSE); m_OrgRegion.InflateRect(-3,-3); m_ResRegion.InflateRect(-3,-3); // Update frame for the cutting object m_oCutter.SetFrame(m_OrgRegion); }