哎 新的工作就是做自己最薄弱的界面部分了...
一大堆东西都不知道 慢慢来吧
东西都记下来
首先就是OutLook样式的分割窗口 + 多视图切换 代码先放着
//更换视图的按钮函数
LRESULT COutBarView::OnOutbarNotify(UINT lParam , LONG wParam)
{
switch(wParam)
{
case IDC_OUT_BAR:
XT_CONTENT_ITEM* pContentItems = m_WndOutLookBar.GetMenuItem((int)lParam);
ASSERT(pContentItems);
CMainFrame *pMainFrame = (CMainFrame *)AfxGetApp()->m_pMainWnd;
switch(lParam)
{
case 0:
pMainFrame->SwitchToView(RED);
break;
case 1:
pMainFrame->SwitchToView(BLACK);
break;
}
}
return 1;
}
//创建Outlook工具栏
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("未能创建工具栏\n");
return -1; // 未能创建
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("未能创建状态栏\n");
return -1; // 未能创建
}
// TODO: 如果不需要工具栏可停靠,则删除这三行
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
//切换View 切换视图
void CMainFrame::SwitchToView(eView nView)
{
CRect rect;
CCreateContext context;
GetClientRect(&rect);
CView* pOldView = (CView* )m_wndSplitter.GetPane(0 , 1);
CDocument* pDoc = (CDocument* )pOldView->GetDocument();
context.m_pCurrentDoc = pDoc;
context.m_pCurrentFrame = this;
context.m_pNewDocTemplate = pDoc->GetDocTemplate();
switch (nView)
{
case RED:
context.m_pNewViewClass = RUNTIME_CLASS(CTestView2);
context.m_pLastView = pOldView;
m_wndSplitter.DeleteView(0 , 1); //删除旧的视图
m_wndSplitter.CreateView(0 , 1 , //创建新视图
RUNTIME_CLASS(CTestView2) , CSize(100, 100) , &context);
break;
case BLACK:
context.m_pNewViewClass = RUNTIME_CLASS(COutBarStyleView);
context.m_pLastView = pOldView;
m_wndSplitter.DeleteView(0 , 1); //删除旧的视图
m_wndSplitter.CreateView(0 , 1 , //创建新视图
RUNTIME_CLASS(COutBarStyleView) , CSize(100, 100) , &context);
break;
}
m_wndSplitter.RecalcLayout();
m_wndSplitter.SetActivePane(0,1);
}
// CMainFrame 消息处理程序
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// 创建切分窗口
if (!m_wndSplitter.CreateStatic(this, 1, 2))
return FALSE;
if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(COutBarView), CSize(100, 100), pContext) ||
!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(COutBarStyleView), CSize(100, 100), pContext))
{
m_wndSplitter.DestroyWindow();
return FALSE;
}
return TRUE; //此处必须返回TRUE才能分割窗口
}
posted on 2009-09-16 10:22
李佳 阅读(633)
评论(0) 编辑 收藏 引用