본문 바로가기

3.구현/VC++

[MFC] 여기저기 긁어모은 코드들

////////////////////////////////////////////////////////////

void CCharSheetView::OnInitialUpdate()
{
    CFormView::OnInitialUpdate();

    CWnd* pwndPropSheetHolder = GetDlgItem(IDC_PLACEHOLDER); // 프로퍼티 시트의 홀더로 픽쳐 컨트롤 사용
    m_pCharPropertySheet = new CCharPropertySheet(_T("-_-v"), pwndPropSheetHolder);
    if(!m_pCharPropertySheet->Create(pwndPropSheetHolder, WS_CHILD | WS_VISIBLE, 0))
    {
        delete m_pCharPropertySheet;
        m_pCharPropertySheet = NULL;
        return;
    }

    // 픽쳐 컨트롤 크기에 맞게 프로퍼티 시트 사이즈 설정
    CRect rectPropSheet;
    pwndPropSheetHolder->GetWindowRect(rectPropSheet);
    m_pCharPropertySheet->SetWindowPos(NULL, 0, 0, rectPropSheet.Width(), rectPropSheet.Height() ,
    SWP_NOZORDER | SWP_NOACTIVATE);
}

////////////////////////////////////////////////////////////

CRect m_rect;
CWnd *pWnd = GetDlgItem(사용할 id);
pWnd->GetWindowRect(&m_rect);
GetClientRect(m_rect);

이렇게 하시면 m_rect에 크기를 얻을수 있습니다.

////////////////////////////////////////////////////////////

void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)
{
   CFrameWnd::OnSizing(fwSide, pRect);

   // Resize the splitter window in the frame. m_SplitWnd is of
   // type CSplitterWnd
   int nWidth=(pRect->right)-(pRect->left);
   m_SplitWnd.SetColumnInfo(0,nWidth/2,10);
   m_SplitWnd.SetColumnInfo(1,nWidth/2,10);
   m_SplitWnd.RecalcLayout();
}

////////////////////////////////////////////////////////////

if (!m_wndSplitter.CreateStatic(this, 2, 1)) {
    TRACE0("Failed to CreateStatic Splitter \n");
    return FALSE;
}

// 사용자가 만든 CxDownloaserInfoView 을 상단에 배치합니다...
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS( CxDownloaderInfoView ), CSize(0,138), pContext)) {
 TRACE0("Failed to create CFormView1 pane \n");
    return FALSE;
}

// 사용자가 만든 CxDownloaderView 을 하단에 배치합니다...
if (!m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS( CxDownloaderView ), CSize(0,0), pContext)) {
    TRACE0("Failed to create CFormView2 pane \n");
    return FALSE;
}

////////////////////////////////////////////////////////////

static_cast<CMainFrame*>(GetParentFrame())->SetSize(CPoint(480, 350));

////////////////////////////////////////////////////////////

CRect rect(10, 10, 50, 50);

rect.DeflateRect(1, 2);

ASSERT(rect.left == 11 && rect.right == 49);
ASSERT(rect.top == 12 && rect.bottom == 48);

CRect rect2(10, 10, 50, 50);
CRect rectDeflate(1, 2, 3, 4);

rect2.DeflateRect(&rectDeflate);
ASSERT(rect2.left == 11 && rect2.right == 47);
ASSERT(rect2.top == 12 && rect2.bottom == 46);

////////////////////////////////////////////////////////////

반응형