其中关于操作的控件加了如下代码:
 1 void CMyDlg::OnAllow() 
 2{
 3 if(!bAllow)
 4 {
5 CMenu *pmenu=GetMenu();
6 CMenu *pSubmenu=pmenu->GetSubMenu(0);
7        pSubmenu->InsertMenu(0,MF_BYPOSITION.IDM_SUM,"求和");
8     pSubmenu->InsertMenu(1,MF_BYPOSITION.IDM_AVERAGE,"求平均");
9 bAllow=TRUE;
10 m_ALLOW.SetWindowText("禁止计算");
11 }
else
{
CMenu *pmenu=GetMenu();
CMenu *pSubmenu=pmenu->GetSubMenu(0);
        pSubmenu->DeleteMenu(IDM_SUM,MF_BYCOMMAND);
    pSubmenu->DeleteMenu(IDM_AVERAGE,MF_BYCOMMAND);
bAllow=FALSE;
m_ALLOW.SetWindowText("允许计算");
}
出现如下错误:
error C2059: syntax error : 'constant'
error C2228: left of '.pSubmenu' must have class/struct/union type
error C2227: left of '->InsertMenuA' must point to class/struct/union
error C2059: syntax error : 'constant'
error C2228: left of '.bAllow' must have class/struct/union type
error C2228: left of '.SetWindowTextA' must have class/struct/union type
Error executing cl.exe.成绩Dlg.obj - 6 error(s), 0 warning(s)
其中第一个错误对应第7行;
2,3,4错误对应第8行;
第5个错误对应第9行;
第6个错误对应第10行;

解决方案 »

  1.   

    这份Ok
    void CMyDlg::OnAllow()
    {
    if(!bAllow)
    {
    CMenu *pmenu=GetMenu();
    CMenu *pSubmenu=pmenu->GetSubMenu(0);
    pSubmenu->InsertMenu(0,MF_BYPOSITION,IDM_SUM,"求和");
    pSubmenu->InsertMenu(1,MF_BYPOSITION,IDM_AVERAGE,"求平均");
    bAllow=TRUE;
    m_ALLOW.SetWindowText("禁止计算");
    }
    else
    {
    CMenu *pmenu=GetMenu();
    CMenu *pSubmenu=pmenu->GetSubMenu(0);
    pSubmenu->DeleteMenu(IDM_SUM,MF_BYCOMMAND);
    pSubmenu->DeleteMenu(IDM_AVERAGE,MF_BYCOMMAND);
    bAllow=FALSE;
    m_ALLOW.SetWindowText("允许计算");
    }
    }
    //          .
      

  2.   

    高手就是高手,解决了。
    是不是那个TRUET和FALSE换了个位置啊?
    那怎么会引来这以多错误啊?
    是不是别的地方也有问题啊?
      

  3.   

    pSubmenu->InsertMenu(0,MF_BYPOSITION.IDM_SUM,"求和");
    8     pSubmenu->InsertMenu(1,MF_BYPOSITION.IDM_AVERAGE,"求平均");---------------------------------------------
    这两行小数点要换成逗号。