iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 27986|回复: 5
打印 上一主题 下一主题

VS2005二次开发菜单问题

[复制链接]
跳转到指定楼层
楼主
发表于 2009-3-31 17:11:27 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
// 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;
}
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 支持支持
沙发
 楼主| 发表于 2009-3-31 17:13:35 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
板凳
发表于 2009-3-31 19:22:20 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
地板
发表于 2010-4-16 14:56:30 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
5
发表于 2010-4-26 16:22:01 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
6
发表于 2010-8-21 16:34:42 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手板模型制作,在线3D打印服务

QQ|小黑屋|手机版|开思工具箱 CAD工具箱_CAM工具箱  

GMT+8, 2024-11-22 04:53 , Processed in 0.013477 second(s), 7 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表