본문 바로가기
C & C++/MFC 컨트롤

Toolbar & Menu

by izen8 2012. 2. 9.
반응형

//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ


CToolBar m_toolbar;
m_toolbar.Create(this);
m_toolbar.LoadToolBar(IDR_TOOLBAR1);
m_toolbar.SetBarStyle(m_toolbar.GetBarStyle() | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

CRect rect; GetClientRect(&rect);
m_toolbar.MoveWindow(0,0,rect.right, 30);

이렇게 해서 생성한다음에.. 나중에 바꿀때는..
void CTest1Dlg::OnButton1()
{
m_toolbar.LoadToolBar(IDR_TOOLBAR2);
m_toolbar.SetBarStyle(m_toolbar.GetBarStyle() | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

CRect rect; GetClientRect(&rect);
m_toolbar.MoveWindow(0,0,rect.right, 30);
}

//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ//ㅡ,ㅡ

 CMenu m_NewMenu;      // 전역으로 선언해야함

 m_NewMenu.Detach();

 //ASSERT(m_NewMenu); 

 SetMenu(NULL);

// 전역으로 bool m_bNewMenu;
 if(m_bNewMenu == false)  // 새메뉴로 바꾸기
 {
  m_NewMenu.LoadMenu(IDR_ChangeWindowTYPE1);
  //m_wndMenuBar.LoadToolBar(IDR_ChangeWindowTYPE1);

  m_bNewMenu = true;

  m_wndToolBar.LoadToolBar(IDR_MAINFRAME1);
  //m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  //m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

  //CRect rect; GetClientRect(&rect);
  //m_wndToolBar.MoveWindow(0,0,rect.right, 30);
 }
 else     // 원래대로 복구
 { 
  m_NewMenu.LoadMenu(IDR_ChangeWindowTYPE);
  //m_wndMenuBar.LoadToolBar(IDR_ChangeWindowTYPE);

  m_bNewMenu = false;

  m_wndToolBar.LoadToolBar(IDR_MAINFRAME);
  //m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  //m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

  //CRect rect; GetClientRect(&rect);
  //m_wndToolBar.MoveWindow(0,0,rect.right, 30);
 }

 // 새롭게 셋팅
 m_wndMenuBar.SetMenu(&m_NewMenu);
 //SetMenu(&m_wndMenuBar);

 // 기본 메뉴로 다시 정함
 m_hMenuDefault = m_NewMenu.m_hMenu;
 //m_hMenuDefault = m_NewMenu.GetSafeHmenu();

 OnUpdateFrameMenu(NULL);
 DrawMenuBar();

반응형

댓글