2개의 툴바를 한줄에 > MFC Tip

본문 바로가기
사이트 내 전체검색

MFC Tip

2개의 툴바를 한줄에

페이지 정보

profile_image
작성자 이즈
댓글 0건 조회 867회 작성일 06-12-27 00:13

본문

MFC로 2개의 툴바를 만들었습니다. 그런데 이 툴바가 한줄씩 따로따로 놓이는군요. 물론 특별히 문제가 되는 것은 아니지만 개인적으로는 툴바를 모두 한줄에 놓고 싶습니다. 나름대로 문서를 찾아보기도 했지만 뾰족한 방법이 없군요. 가령 다음과 같은 코드에서 툴바를 한줄에 모으려면 어떻게 해야 합니까?

class CMainFrame : public CFrame
{
protected:
    CToolBar wnd_myToolBar;
    CToolBar wnd_othToolBar;
    ...
};

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...
    wnd_myToolBar.Create(...);
    wnd_othToolBar.Create(...);
    ...
}

DockControlBarLeftOf 함수를 이용하면 가능합니다. DockControlBarLeftOf(CToolBar* Bar, CToolBar* LeftOf)처럼 두 개의 툴바를 인수로 받기 때문입니다. 따라서 Bar와 LeftOf 툴바는 한줄에 출력될 것입니다. 다음 코드를 참고하기 바랍니다.

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    ...
    EnableDocking(CBRS_ALIGN_ANY);

    m_wndToolBar.SetWindowText(_T("myToolBar"));
    m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndToolBar, AFX_IDW_DOCKBAR_TOP);

    wnd_othToolBar.SetWindowText(_T("otherToolBar"));
    wnd_othToolBar.EnableDocking(CBRS_ALIGN_ANY);
    DockControlBarLeftOf(&m_wndToolBar, &wnd_othToolBar);
  ...
}

void CMainFrame::DockControlBarLeftOf(CToolBar* Bar,CToolBar* LeftOf)
{
    CRect rect;
    DWORD dw;
    UINT n;
    // get MFC to adjust the dimensions of all docked ToolBars
    // so that GetWindowRect will be accurate
    RecalcLayout();
    LeftOf->GetWindowRect(&rect);
    rect.OffsetRect(1,0);

    dw=LeftOf->GetBarStyle();
    n = 0;
    n = (dw&CBRS_ALIGN_TOP) ? AFX_IDW_DOCKBAR_TOP : n;
    n = (dw&CBRS_ALIGN_BOTTOM && n==0) ? AFX_IDW_DOCKBAR_BOTTOM : n;
    n = (dw&CBRS_ALIGN_LEFT && n==0) ? AFX_IDW_DOCKBAR_LEFT : n;
    n = (dw&CBRS_ALIGN_RIGHT && n==0) ? AFX_IDW_DOCKBAR_RIGHT : n;
    // When we take the default parameters on rect, DockControlBar will dock
    // each Toolbar on a seperate line. 
    // By calculating a rectangle, we in effect
    // are simulating a Toolbar being dragged to that location and docked.
    DockControlBar(Bar,n,&rect);
}

댓글목록

등록된 댓글이 없습니다.

Total 172건 7 페이지

검색

회원로그인

회원가입

사이트 정보

컴퓨터 정보,윈도우즈,리눅스,포토샵,3ds
맥스,프로그래밍 강좌팁

접속자집계

오늘
805
어제
558
최대
5,287
전체
630,910
Copyright © www.qdata.co.kr All rights reserved.