有两个困扰我好久的问题CSplitter和消息响应
我在MainFrame里定义了一个CSplitterWnd 的wnd在OnCreatClient函数中写了
wnd.CreateStatic(this,2,1);
CRect r;
GetClientRect(&r);
CSize p(r.right/2,r.bottom/2);
wnd.CreateView(0,0,RUNTIME_CLASS(CTRYView),p,pContext);
wnd.CreateView(1,0,RUNTIME_CLASS(CTRYView),p,pContext);
return true;
在MainFrame.cpp中加入了#include "tryview.h"
可是在编译时有三个错误:
1:tryview.h(21) : error C2143: syntax error : missing ';' before '*':
2:tryview.h(21) : error C2501: 'CTRYDoc' : missing storage-class or type specifiers:
3:tryview.h(21) : error C2501: 'GetDocument' : missing storage-class or type specifiers:
三个错误都是针对
tryview.h中的
CTRYDoc* GetDocument();
当我把GetDocument这个函数删除 包括删除GetDocument时带来的其他问题 时问题解决 可是又如何得到文档呢?
这是一个动态菜单的程序
FILE COLOR VIEW
…… BLUE STANDARD
RED EXPAND
——
GREEN
YELLOW
程序一开始EXPAND可用STANDARD disable以后交替
分割线及下面的都是在EXPAND按下后出现在STANDARD按下后消失的
view.h中
afx_msg void OnUpdateOptions(CCmdUI* pCmdUI);
view.cpp中
ON_UPDATE_COMMAND_UI_RANGE(ID_STANDARD,ID_EXPAND, OnUpdateOptions)
ID_STANDARD,ID_EXPAND为两个菜单的ID号
void CDynMenuView::OnUpdateOptions(CCmdUI* pCmdUI)
{
CMenu *pAddinMenu, *pTopMenu;
pTopMenu = AfxGetMainWnd()->GetMenu();
pAddinMenu = pTopMenu->GetSubMenu(1);
switch (pCmdUI->m_nID)
{
case ID_EXPAND:pCmdUI->Enable(pAddinMenu->GetMenuItemCount() == 2);
break;
case ID_STANDARD:
pCmdUI->Enable(pAddinMenu->GetMenuItemCount() != 2);break;
}
}
这个函数好像只是把菜单给disable掉 没有enable可是在实际中好像也会enable(我把switch后的语句删掉就不会disable 一开始就可用 怎么回事?