iCAx开思网

标题: VS2005二次开发菜单问题 [打印本页]

作者: xiaoboliang    时间: 2009-3-31 17:11
标题: VS2005二次开发菜单问题
// menubar5.cpp : 定义 DLL 的初始化例程。
//
#include "stdafx.h"
#include "ProToolkit.h"
#include "user_tk_error.h"
#include "pro_wchar_t.h"
#include "ProMdl.h"
#include "ProMenu.h"
#include "ProMenuBar.h"
#include "ProMessage.h"
#include "ProNotify.h"
#include "ProObjects.h"
#include "ProUtil.h"
#include "ProUIDialog.h"
#include "ProUIMessage.h"
#include "ProUIPushbutton.h"
#include "ProSolid.h"
#include "ProWindows.h"
#include "ProFamtable.h"
#include "ProFaminstance.h"
#include "ProUICmd.h"
#include "TestError.h"
#include "ProParamval.h"


/*----------------------------------------------------------------------------*\
Application data types
\*----------------------------------------------------------------------------*/
extern "C"typedef struct user_command
{
    char *name;
    uiCmdCmdId id;
} UserCommand;
extern "C"typedef struct user_check_but
{
    uiCmdCmdId command;
    ProBoolean state;
} UserCheckBut;

/*----------------------------------------------------------------------------*\
Application global/external data
\*----------------------------------------------------------------------------*/
extern "C"static wchar_t msgfil[] =
    { 'm','e','n','u','b','a','r','_','m','s','g','.','t','x','t','\0'};
extern "C"static UserCheckBut check_but[2];
extern "C"static uiCmdAccessState access_state = ACCESS_AVAILABLE;
extern "C"static FILE *log_file = NULL;
extern "C"static UserCommand user_actions[] = {
{"TestCheckButtonOpt1", (uiCmdCmdId)NULL},
{"TestCheckButtonOpt2", (uiCmdCmdId)NULL},
{"TestRadioGroupOpt",  (uiCmdCmdId)NULL}};


/*====================================================================*\
    FUNCTION : ProTestAccessFunction()
    PURPOSE  :   Enable access
\*====================================================================*/
extern "C"static uiCmdAccessState ProTestAccessFunction(uiCmdAccessMode access_mode)
{
   
    return (ACCESS_AVAILABLE);
}


/*====================================================================*\
    FUNCTION : ProTestRadioButtonValue()
    PURPOSE  :  Set value for radio group
\*====================================================================*/
extern "C"int ProTestRadioButtonValue(
    uiCmdCmdId command,
    uiCmdValue *p_value)
{
    ProError err;
    ProMenuItemName  name;

#if 0
    err = ProMenubarMenuRadiogrpValueGet (p_value, name);
   
    err = ProMenubarMenuRadiogrpValueSet(p_value, name);
   
#endif
    return (0);
}
/*====================================================================*\
    FUNCTION : ProTestRadioButton()
    PURPOSE  :  Callback functions for radio group options
\*====================================================================*/
extern "C"int ProTestRadioButton(
    uiCmdCmdId command,
    uiCmdValue *p_value)
{
    ProError err;
    ProMenuItemName  name;   
   
   
    err = ProMenubarMenuRadiogrpValueGet (p_value, name);
  
    return(0);
}
/*====================================================================*\
    FUNCTION : ProTestCheckButtonValue()
    PURPOSE  :  Set new value for check buttons
\*====================================================================*/
extern "C"int ProTestCheckButtonValue(
    uiCmdCmdId command,
    uiCmdValue *p_value)
{
    ProError err;
    ProBoolean bool;
    int i;

    for (i=0; i<sizeof(check_but)/sizeof(check_but[0]); i++)
if (check_but[i].command == command)
{
         err = ProMenubarmenuChkbuttonValueGet (p_value, &bool);
     

     if (bool == check_but[i].state)
  continue;
     
   
     err = ProMenubarmenuChkbuttonValueSet(p_value, check_but[i].state);
   
     break;
}
    return(0);
}
/*====================================================================*\
    FUNCTION : ProTestCheckButton()
    PURPOSE  :  Callback function for check button options
\*====================================================================*/
extern "C"int ProTestCheckButton(   
    uiCmdCmdId command,
    uiCmdValue *p_value,
    void *p_push_command_data)
{
    int i;
   
    ProMessageDisplay(msgfil, "TEST Check Button pressed.");
    for (i=0; i<sizeof(check_but)/sizeof(check_but[0]); i++)
if (check_but[i].command == command)
{
     /*  Change state of pressed button */
     check_but[i].state = !check_but[i].state;
     break;
}
    return(0);
}


/*============================================================================*\
  Function : ProTestMenuBar
  Purpose  : Create a menu to test Menu Bar functions
\*============================================================================*/
extern "C"int ProTestMenuBar()
{
   
    ProError err;
    uiCmdCmdId   push_act, push_act2, action;
    uiCmdCmdId   radio_act;
    int i;
    static ProMenuItemName radio_group_items[]=
{"TestRadio1", "TestRadio2", "TestRadio3", ""};
    static ProMenuItemLabel radio_group_labels[]=
{"Radio button 1", "Radio button 2", "Radio button 3", ""};
    static ProMenuLineHelp radio_group_help[]=
{"Test radio button", "Test radio button", "Test radio button", ""};
/*---------------------------------------------------------------------*\
    Add new button to the menu bar
\*---------------------------------------------------------------------*/
    err = ProMenubarMenuAdd( "TestMenuBar", "-MenuBar", "Help", PRO_B_FALSE,
msgfil);
   

    err = ProCmdOptionAdd("TestCheckButtonOpt1",
(uiCmdCmdActFn)ProTestCheckButton, PRO_B_TRUE,
(uiCmdCmdValFn)ProTestCheckButtonValue,
ProTestAccessFunction, PRO_B_TRUE, PRO_B_TRUE, &check_but[0].command);
    err = ProCmdOptionAdd("TestCheckButtonOpt2",
(uiCmdCmdActFn)ProTestCheckButton, PRO_B_TRUE,
(uiCmdCmdValFn)ProTestCheckButtonValue,
ProTestAccessFunction, PRO_B_TRUE, PRO_B_TRUE, &check_but[1].command);
   
    err = ProCmdOptionAdd("TestRadioGroupOpt",
(uiCmdCmdActFn)ProTestRadioButton, PRO_B_FALSE,
(uiCmdCmdValFn)ProTestRadioButtonValue,
ProTestAccessFunction, PRO_B_TRUE, PRO_B_TRUE, &radio_act);
   
   
   
    err = ProMenubarmenuChkbuttonAdd("TestMenuBar", "TestChkBut1",
"Check button 1",
"Test check button 1",NULL, PRO_B_TRUE, check_but[0].command,
msgfil);

    err = ProMenubarmenuChkbuttonAdd("TestMenuBar", "TestChkBut2", "Check button 2",
"Test check button 2", "TestChkBut1", PRO_B_TRUE, check_but[1].command,
msgfil);
   
    err = ProMenubarmenuRadiogrpAdd("TestMenuBar", "TestRadioGrp1",
3, radio_group_items, radio_group_labels, radio_group_help,
"TestChkBut2", PRO_B_TRUE, radio_act, msgfil);
   
    return(0);
}
extern "C"int user_initialize()
{
ProTestMenuBar();

return 0;
}
/*---------------------------------------------------------------------------*\
    End the Pro/TOOLKIT application
\*---------------------------------------------------------------------------*/
extern "C"void user_terminate()
{
     return;
}
作者: xiaoboliang    时间: 2009-3-31 17:13
编译结果为:1>d:\backup\visual studio 2005\projects\menubar5\menubar5\menubar5.cpp(88) : warning C4101: “name”: 未引用的局部变量
1>d:\backup\visual studio 2005\projects\menubar5\menubar5\menubar5.cpp(87) : warning C4101: “err”: 未引用的局部变量
1>d:\backup\visual studio 2005\projects\menubar5\menubar5\menubar5.cpp(128) : error C2628: “ProBoolean”后面接“bool”是非法的(是否忘记了“;”?)
1>d:\backup\visual studio 2005\projects\menubar5\menubar5\menubar5.cpp(137) : error C2062: 意外的类型“bool”
1>d:\backup\visual studio 2005\projects\menubar5\menubar5\menubar5.cpp(140) : error C2059: 语法错误 : “==”
1>d:\backup\visual studio 2005\projects\menubar5\menubar5\menubar5.cpp(171) : error C2440: “=”: 无法从“bool”转换为“ProBoolean”
1>        转换为枚举类型要求显式转换(static_cast、C 样式转换或函数样式转换)

我的附加的库

wsock32.lib
mpr.lib
psapi.lib
protk_dllmd.lib
预处理器定义添加:PRO_USE_VAR_ARGS
请问究竟哪里出问题了?
作者: 5I3D    时间: 2009-3-31 19:22
没玩过这么加菜单的。
作者: hechao922    时间: 2010-4-16 14:56
我也遇到这样的问题啊,都是教材上的程序,怎么会出这样的错呢,兄弟问题解决了吗??
作者: baibai541022    时间: 2010-4-26 16:22
同求,为什么老是这种问题呢
作者: F1642556    时间: 2010-8-21 16:34
我也是学习中。。。。。。。。找资料




欢迎光临 iCAx开思网 (https://www.icax.org/) Powered by Discuz! X3.3