我作了一个类似outlook的界面,然后想切换视图总是失败。请问如何切换啊?
解决方案 »
- SDI中误删string table后,怎样恢复打开文件对话框中的默认扩展名?
- CEdit 控件的问题
- mkdir 创建文件夹后 用SHFILEOPSTRUCT 为什么不能删除此文件夹???
- 高薪聘请"COM高手"作顾问
- 能不能用一个modem拨通另一个modem,同时实现两个modem之间的数据传输?
- 谁知道哪个函数能将char(1字节)数组转为short(2字节)数组?
- jiangsheng大侠进来,我知道你在--MSVCer
- 坐标系的问题
- 请教高手解决问题
- 谁有有关坐标转换的代码?帮帮忙吧!
- 怎样判断当前进程是否系统进程?
- 我在创建分割窗口时候编译没有错误,执行后说是建立空文档失败,各位有相关经历吗?
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
中创建了左侧的outlookbar,然后想切换视图。
在用getactiveview()获取活动视图时出错,不能获取当前活动视图的指针。如果不创建outlookbar,就不存在这个问题。
是不是createclient的原因? 其代码如下:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// Create the splitter window with two columns
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
TRACE0("Failed to create splitter window\n");
return FALSE;
}
// "Flexible pane": The second pane may present its own
// splitter windows.
if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CContainerView),
CSize(0, 0), pContext))
{
TRACE0("Failed to create CContainerView\n");
return FALSE;
} DWORD dwStyle =
CGfxOutBarCtrl::fDragItems |
CGfxOutBarCtrl::fEditGroups |
CGfxOutBarCtrl::fEditItems |
CGfxOutBarCtrl::fRemoveGroups |
CGfxOutBarCtrl::fRemoveItems |
CGfxOutBarCtrl::fAddGroups |
CGfxOutBarCtrl::fAnimation;
// Here we create the outbar control; we give as id the parent splitter pane id here
if (!m_wndOutlookBar.Create(WS_CHILD|WS_VISIBLE, CRect(0,0,0,0),
&m_wndSplitter, m_wndSplitter.IdFromRowCol(0, 0), dwStyle))
{
TRACE0("Failed to create outlook bar.");
return FALSE;
}
// Tell the control to send message to this window (the mainframe)
// and not to its real parent (the splitter)
m_wndOutlookBar.SetOwner(this);
// Here we create the imagelists for the control
m_ImageSmall.Create (16, 16, TRUE, 2, 1);
m_ImageLarge.Create (32, 32, TRUE, 2, 1); for( int nIcon = IDI_ICON_OUTLOOK; nIcon <= IDI_ICON_PUBLIC; ++nIcon )
{
HICON hIcon = AfxGetApp()->LoadIcon(nIcon);
ASSERT(hIcon); m_ImageSmall.Add(hIcon);
m_ImageLarge.Add(hIcon);
} // and we link them to the control
m_wndOutlookBar.SetImageList(&m_ImageLarge, CGfxOutBarCtrl::fLargeIcon);
m_wndOutlookBar.SetImageList(&m_ImageSmall, CGfxOutBarCtrl::fSmallIcon); m_wndOutlookBar.SetAnimationTickCount(20);
m_wndOutlookBar.SetAnimSelHighlight(200); // Look at function reference for information about linking image list
// Here we can add the folders to the control; we need at least one folder.
// The numbers aside the text are an "lParam" value we can assign to each folder
m_wndOutlookBar.AddFolder(_T("Outlook Shortcuts"), FOLDER_0);
m_wndOutlookBar.AddFolder(_T("My Shortcuts"), FOLDER_1); // Here we insert the items; syntax is folder, index, text, image, lParam value for item
m_wndOutlookBar.InsertItem(FOLDER_0, CMD_00, _T("Outlook Today"), 0, 0);
m_wndOutlookBar.InsertItem(FOLDER_0, CMD_01, _T("Inbox"), 1, 0);
m_wndOutlookBar.InsertItem(FOLDER_0, CMD_02, _T("Calendar"), 2, 0);
m_wndOutlookBar.InsertItem(FOLDER_0, CMD_03, _T("Contacts"), 3, 0);
m_wndOutlookBar.InsertItem(FOLDER_0, CMD_04, _T("Tasks"), 4, 0);
m_wndOutlookBar.InsertItem(FOLDER_0, CMD_05, _T("Journal"), 5, 0);
m_wndOutlookBar.InsertItem(FOLDER_0, CMD_06, _T("Notes"), 6, 0);
m_wndOutlookBar.InsertItem(FOLDER_0, CMD_07, _T("Deleted Items"), 7, 0);
m_wndOutlookBar.InsertItem(FOLDER_1, CMD_00, _T("Drafts"), 8, 0);
m_wndOutlookBar.InsertItem(FOLDER_1, CMD_01, _T("Outbox"), 9, 0);
m_wndOutlookBar.InsertItem(FOLDER_1, CMD_02, _T("Sent Items"), 10, 0);
m_wndOutlookBar.SetSelFolder(0); // Standard sizing for splitter
CRect r;
GetClientRect(&r);
int w1 = r.Width()/7;
int w2 = r.Width()/5;
m_wndSplitter.SetColumnInfo( 0, w1, 0 );
m_wndSplitter.SetColumnInfo( 1, w2, 0 );
m_wndSplitter.RecalcLayout(); return TRUE;
}