高分请教一个OutLook风格的用户界面的使用问题
我从http://code.knowsky.com/down/6488.html下载了一个OutLook风格的用户界面,我现在想做如下改动,我改的总是出错,所以请教一下大家。
做如下改动:
1、单击左边Item1,不是弹出对话,而是右侧视图变换为CView1(我自己创建的一个派生自CFormView类)
2、单击左侧Item2 ,不是弹出对话,而是右侧视图变换为CView2(我自己创建的一个派生自CFormView类)
我自己做的总是实现不了,请大家帮帮忙。
我如果按照你提供的方法能够实现,马上给分!
在线等,急!
我的邮箱:liwei19820806@163.com,可以把改好的源代码发给我!
问题点数:100、回复次数:20Top
1 楼DentistryDoctor(不在无聊中无奈,就在沉默中变态)回复于 2006-07-03 22:03:48 得分 0
用成熟的界面库吧,比如BCGTop
2 楼liwei19820806(花开看花落)回复于 2006-07-03 22:32:00 得分 0
楼上的,我用了BCG v6.4,但通过AppWizard生成的Outlookbar不如这个漂亮,而且通过BCG产生的OutlookBar不能改变item内容,比如BCG默认三个Pane,每个Pane里面2个item,但名字都是固定死的shortcut1,shortcut2,我怎么改不自己想要的名字>?请问楼上怎么解决?!Top
3 楼goodboyws(深夜不眠者(VCMVP))回复于 2006-07-04 00:27:52 得分 30
给你几个其他例子
http://www.codeguru.com/cpp/frameworks/advancedui/outlookcontrols/article.php/c6881/
http://www.codeguru.com/Cpp/controls/controls/article.php/c2155Top
4 楼whwjn(哈哈)回复于 2006-07-04 01:02:32 得分 0
创建一个分割视图,左边是BCG库里面的Pager控件,右边是一个从CFrameWnd派生出来的
框架,在里面创建CView1和CView2,然后根据需要隐藏CView1或者CView2Top
5 楼liwei19820806(花开看花落)回复于 2006-07-04 09:59:29 得分 0
http://www.codeguru.com/Cpp/controls/controls/article.php/c2155
和我给出的是一样的,但我在此基础上修改的总是出错,那位大虾不要在这动嘴,动个手试试,如果能搞定,请说一声,100分马上送上!!Top
6 楼liwei19820806(花开看花落)回复于 2006-07-04 10:20:57 得分 0
更正一下:我的是根据http://www.codeguru.com/Cpp/controls/controls/article.php/c2155改的,我1楼打的网址不对!!!Top
7 楼tyscon(但为君故)回复于 2006-07-04 10:59:00 得分 0
用bcgcontrolbar pro 9吧,很漂亮的。Top
8 楼lisypro()回复于 2006-07-04 11:56:10 得分 0
UPTop
9 楼xiao_fang(frank)回复于 2006-07-04 14:55:28 得分 50
// 在OnOutbarNotify进行视图切换:
long CMainFrame::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
{
switch (wParam)
{
case NM_FOLDERCHANGE:
// cast the lParam to an integer to get the clicked folder
TRACE1("Folder Change to: %d\n", (int) lParam);
m_nCurFolder = (int) lParam;
return 0;
case NM_OB_ITEMCLICK:
// cast the lParam to an integer to get the clicked item
{
int index = (int)lParam;
TRACE2("SwitchToView: %d lParam: %d\n", index, (int)lParam );
m_pSubFrame->SwitchToView(index);
return 0;
}
case NM_OB_ONLABELENDEDIT:
// cast the lParam to an OUTBAR_INFO * struct; it will contain info about the edited item
// return 1 to do the change and 0 to cancel it
return 1;
case NM_OB_ONGROUPENDEDIT:
// cast the lParam to an OUTBAR_INFO * struct; it will contain info about the edited folder
// return 1 to do the change and 0 to cancel it
return 1;
case NM_OB_DRAGITEM:
// cast the lParam to an OUTBAR_INFO * struct; it will contain info about the dragged items
// return 1 to do the change and 0 to cancel it
return 1;
}
return 0;
}
//视图切换:
void CSubFrame::SwitchToView(UINT nView)
{
if(nView == m_nCurView)
return;
CView* pOldActiveView = GetActiveView();
CView* pNewActiveView = (CView*) GetDlgItem(nView);
if (pNewActiveView == NULL)
{
TRACE1("dynamic create view: %d\n", nView);
switch (nView)
{
case ID_FORM_SETTING:
pNewActiveView = m_pSettingForm = new CSettingForm;
break;
case ID_FORM_MATERIAL:
pNewActiveView = m_pMaterialForm = new CMaterialForm;
break;
default:
ASSERT(FALSE);
}
CCreateContext context;
context.m_pCurrentDoc = pOldActiveView->GetDocument();
pNewActiveView->Create(NULL, NULL, 0L, //WS_BORDER
CFrameWnd::rectDefault, this, nView, &context);
// call OnInitialUpdate explicitly
pNewActiveView->OnInitialUpdate();
}
if (pNewActiveView)
{
// don't switch when views are the same
if (pOldActiveView != pNewActiveView)
{
SetActiveView(pNewActiveView);
pNewActiveView->ShowWindow(SW_SHOW);
pNewActiveView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
ASSERT_VALID(pOldActiveView);
pOldActiveView->ShowWindow(SW_HIDE);
pOldActiveView->SetDlgCtrlID(m_nCurView);
m_nCurView = nView;
}
RecalcLayout();
}
}
// 我这里m_pSubFrame 是用来管理右边的多视的
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if (!wndSplitter.CreateStatic(this, 1, 2))
return false;
// 右边用一个CFrameWnd派生的CSubFrame来管理多个视图
if (!wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CSubFrame), CSize(0,0), pContext))
return false;
m_pSubFrame = (CSubFrame*)wndSplitter.GetPane(0, 1);
// ...
wndBar.Create(WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), &wndSplitter, wndSplitter.IdFromRowCol(0, 0), dwf);
// Tell the control to send message to this window (the mainframe) and not to its real parent (the splitter)
wndBar.SetOwner(this);
return true;
//return CFrameWnd::OnCreateClient(lpcs, pContext);
}
hope help:)Top
10 楼liwei19820806(花开看花落)回复于 2006-07-04 16:29:19 得分 0
楼上大虾的方法似乎可行,但有一些bug,有时Debug可以,然后关了再Debug就不行了,我跟踪调试了一下,问题出在SwitchToView的CView* pOldActiveView = GetActiveView(),得到的值是NULL,这样在后面context.m_pCurrentDoc = pOldActiveView->GetDocument()时就出错了,请问楼上大虾怎么解决啊??急!!!Top
11 楼liwei19820806(花开看花落)回复于 2006-07-04 18:51:25 得分 0
顶我自己一下!Top
12 楼liwei19820806(花开看花落)回复于 2006-07-04 19:39:45 得分 0
xiao_fang(frank):
能否给我发一份你作的源代码,我的邮箱liwei19820806@163.com
谢谢!
Top
13 楼DrSmart(斯玛特)回复于 2006-07-04 22:34:49 得分 0
样子看着还行Top
14 楼xiao_fang(frank)回复于 2006-07-05 08:59:54 得分 0
This is only a sample, you'd modify it according to your needs.
you may try this way:
CWnd *pWnd = splitter->GetPane(0,1) // get right wnd via splitterwnd
Notice: in my code, it's the SubFrame wnd, but maybe it's your right view. Debug it and watch the pWnd's class type which will help you to find out the active view you want.
I've provide enough code to point the way for you, think it over and you'll solve your problem.
good luck.Top
15 楼loomman(一剑)回复于 2006-07-05 09:17:25 得分 0
BCG,cjlib都不错
推荐LZ采用Top
16 楼wntjc()回复于 2006-07-05 11:35:24 得分 20
参照一下,SDI:
BOOL CMyDocument::SwitchToView(CRuntimeClass* pNewViewClass)
{
CFrameWnd* pMainWnd = (CFrameWnd*)AfxGetMainWnd();
CView* pOldActiveView = pMainWnd->GetActiveView();
// If we're already displaying this kind of view, no need to go further.
if (pOldActiveView->IsKindOf(pNewViewClass))
return TRUE;
// Set the child window ID of the active view to AFX_IDW_PANE_FIRST.
// This is necessary so that CFrameWnd::RecalcLayout will allocate
// this "first pane" to that portion of the frame window's client
// area not allocated to control bars. Set the child ID of
// the previously active view to some other ID.
::SetWindowLong(pOldActiveView->m_hWnd, GWL_ID, 0);
// create the new view
CCreateContext context;
context.m_pNewViewClass = pNewViewClass;
context.m_pCurrentDoc = this;
CView* pNewView = STATIC_DOWNCAST(CView, pMainWnd->CreateView(&context));
if (pNewView != NULL)
{
// the new view is there, but invisible and not active...
pNewView->ShowWindow(SW_SHOW);
pNewView->OnInitialUpdate();
pMainWnd->SetActiveView(pNewView);
pMainWnd->RecalcLayout();
// destroy the old view...
pOldActiveView->DestroyWindow();
return TRUE;
}
return FALSE;
}
Top
17 楼liwei19820806(花开看花落)回复于 2006-07-05 23:54:04 得分 0
我放弃了,决定使用BCGControlBar了。但使用中出现问题:我使用AppWizard生成Outlookbar,但名字都是固定死的shortcut1,shortcut2,我怎么改不自己想要的名字>?还有我用的是BCGControlBar 6.4,但似乎不支持中文,请问怎么解决?Top
18 楼liwei19820806(花开看花落)回复于 2006-07-06 02:01:24 得分 0
在线等!Top
19 楼xiao_fang(frank)回复于 2006-07-09 11:17:08 得分 0
从你问的问题看,你做这个有点操之过急,好好看看书和VC例程吧,先写些小程序:)Top
20 楼liwei19820806(花开看花落)回复于 2006-07-10 00:28:54 得分 0
哦,问题我早已解决了。xiao_fang(frank),你给的代码确实有BUG,你自己可以测试。
感谢大家,给大家散分!Top




