QQ登录

只需一步,快速开始

快捷登录

登录 或者 注册 请先

UG爱好者

查看: 15142|回复: 18
打印 上一主题 下一主题

[分享] 小白学UG二次开发_UG菜单栏和UG Block编程

[复制链接]

三级士官

Rank: 3Rank: 3

11

主题

54

帖子

641

积分
跳转到指定楼层
楼主
发表于 2015-3-25 11:02:12 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本例参考UG自动生成的代码文件还有《基于UG NX系统的二次开发》周临震等. 另外感谢Murry对我的帮助。
以下代码由前面小白学UG二次开发_UGOpen UIStyler 对话框设计文中所举例子生成的C代码,如上例所说,该代码提供了分别由菜单栏、blockuser exit三种不同的方式调用UI block的方式。本例主要采用从菜单栏进入的方式来实现对对话框的调用。现在对环境变量的设置十分疑惑,书中每举一个例子,都会设置一次环境变量,而且都是不同的。不知道这个会不会冲突,比如我同时要使用这几个功能时,这个环境变量该怎么设置。有朋友建议我去看看帮助文件。
另外,加载菜单文件时,需要现在UGII下的custom_dirs.dat中添加目录地址,如D:UGOPEN
另外,在该目录下面设置application文件和startup文件。
/* These includefiles are needed for the following template code.            */
#include <stdio.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_exit.h>
#include <uf_ui.h>
#include <uf_styler.h>
#include <uf_mb.h>
#include "access_dialog.h"
/* The followingdefinition defines the number of callback entries */
/* in the callbackstructure:                                     */
/*UF_STYLER_callback_info_t DIALOG_ACCESS_cbs */
#define DIALOG_ACCESS_CB_COUNT ( 3 + 1) /* Add 1 for the terminator */
/*--------------------------------------------------------------------------
The followingstructure defines the callback entries used by the      
styler file.  This structure MUST be passed into the userfunction,   
UF_STYLER_create_dialogalong with DIALOG_ACCESS_CB_COUNT.                       
--------------------------------------------------------------------------*/
static UF_STYLER_callback_info_tDIALOG_ACCESS_cbs[DIALOG_ACCESS_CB_COUNT] =
{
{UF_STYLER_DIALOG_INDEX, UF_STYLER_APPLY_CB        , 0,DIALOG_ACCESS_apply_cb},
{UF_STYLER_DIALOG_INDEX, UF_STYLER_BACK_CB         , 0,DIALOG_ACCESS_back_cb},
{DIALOG_ACCESS_BUTTON  , UF_STYLER_ACTIVATE_CB     , 0,DIALOG_ACCESS_action_3_act_cb},
{UF_STYLER_NULL_OBJECT, UF_STYLER_NO_CB, 0, 0 }
};
/*--------------------------------------------------------------------------
UF_MB_styler_actions_tcontains 4 fields.  These are defined asfollows:
Field 1 : the nameof your dialog that you wish to display.
Field 2 : any clientdata you wish to pass to your callbacks.
Field 3 : yourcallback structure.
Field 4 : flag toinform menubar of your dialog location. This flag MUST match the resource set in your dialog!  Do NOT ASSUME that changing this field willupdate the location of your dialog. Please use the UIStyler to indicate the position of your dialog.
--------------------------------------------------------------------------*/
static UF_MB_styler_actions_tactions[] = {
    { "access_dialog.dlg",  NULL,   DIALOG_ACCESS_cbs,  UF_MB_STYLER_IS_NOT_TOP },
    { NULL,  NULL,  NULL,  0 } /* Thisis a NULL terminated list */
};
/*----------------MENUBAR HOOKUP HELP Example -------------------
To launch thisdialog from a Unigraphics menubar, you must follow
the steps below.
1)  Add the following lines to your MenuScriptfile in order to associate a menu bar button with your dialog.  In this example, a cascade menu will becreated and will be located just before the Help button on the main menubar. Thebutton, ACCESS_DIALOG_BTN is set up to launch your dialog and will bepositioned as the first button on your pulldown menu.If you wish to add thebutton to an existing cascade, simply add the 3 lines between MENULAUNCH_CASCADE and END_OF_MENU  to yourmenuscript file.  
    增加以下几行到你的MenuScript文件中用以链接菜单栏按钮和对话框。在这个例子中,一个层叠菜单将会在主菜单栏的HELP选项前创建。该按钮,ACCESS_DIALOG_BTN 是设置起来用以触发你的对话框并且将会出现在第一个下拉菜单按钮中。如果你希望增加该按钮到你现有的层叠菜单里,仅需要增加 MENU LAUNCH_CASCADE END_OF_MENU之间的三行到你的Menuscript文件中。
    The MenuScript file requires an extension of".men".
    Make sure that you add the extension to thefile and place the file in your startup directory:
      $UGII_USER_DIR/startup or
      $UGII_SITE_DIR/startup or
      $UGII_VENDOR_DIR/startup directory
   MenuScript 文件需要以.men作为扩展名,确保你将该文件的扩展名改成.men,并将该文件下放到以下的目录中去。(注意:三选一)
    Move the contents between the dashed linesto your Menuscript file.
!  ----------------------------------------------------------------
VERSION120
菜单脚本的版本号,在系统菜单文件、用户文件中,无论是编辑模式还是创建模式,第一行通常就是版本号说明。但是版本号,为啥是120?
EDITUG_GATEWAY_MAIN_MENUBAR
EDIT 编辑模式菜单文件的标志,编辑的对象应该是已经创建好的菜单,在关键字EDIT之后指出所编辑菜单的标示符,用户的菜单尽量采用编辑模式。
BEFOREUG_HELP
BEFORE 在已有的菜单文件中定义的某个菜单项之前加上一个新项。 这里是UG_HELP,相对应的,也有AFTER,之后都要用END_OF_BEFORE or END_OF_AFTER来结束。
      CASCADE_BUTTON UISTYLER_DLG_CASCADE_BTN
CASCADE_BUTTON  层叠菜单项。当它激活时打开一个子菜单,每一个级联按钮的定义,必须用MENU定义相同的菜单名。这个从下面的可以看出来。子菜单既可以在级联按钮前定义,也可以在级联按钮菜单后定义。
      LABEL Dialog Launcher
Label 菜单项名称,也就是我们看到的名称。
    END_OF_BEFORE
    MENU UISTYLER_DLG_CASCADE_BTN   前面提到过了,名字要对应
      BUTTON ACCESS_DIALOG_BTN        BUTTON 是在菜单栏中添加一个项,如果有两个项,就在ACTIONS 后面再加一个BUTTON
      LABEL Display access_dialog dialog
      ACTIONS access_dialog.dlg   ACTIONS表面你要执行的动作,可以有:NX系统定义的标准命令、用户定义的回调函数、一个对话框文件名称,一个GRIP程序、一个工具栏文件、操作系统的命令以及OPEN C and C++ Program的程序名称。
    END_OF_MENU   非顶层菜单定义结束
!  ---------------------------------------------------------------
上面这些就是下拉菜单的代码。因为我的UG是中文版的,所以加载后Dialog Launcher直接就被转换成了启动对话框,下拉菜单中的Display access_dialogdialog还是保持英文的状态。
2) Issue a call tothe function, UF_MB_add_styler_actions from the ufsta
   user exit as shown below.  To use this call, remove the conditional
   definitions: #ifdef MENUBAR_COMMENTED_OUT
                 #endif MENUBAR_COMMENTED_OUT
   如下所示,从ufstauser exit 发出调用 UF_MB_add_styler_actions请求。(这个翻译我不是很确定。)
   要调用这一段函数,需要去除条件定义。
   The static structure, actions, will allowyou to associate ALL of your
dialogs and callback functions to the  menubar at once.  For example, if you wish to have 10 dialogsassociated to 10 different buttons on the menubar,you may enter each dialog andcallback list into the actions structure. Make sure that you have created a corresponding button in your MenuScript file.
   Static structure,actions将会允许你在下拉菜单中链接所有你的对话框和回调函数。比如,如果你想让
   十个对话框和十个不同的下拉菜单中的按钮一一对应的话,你需要将每一个对话框和回调列表(list)到你的actions
   structure 中去。确保你已经在MenuScript文件中创建一个响应按钮。
   You may also have separate shared libraries,each with a ufsta user exit
   for each individual dialog.
3) Place yourcompiled and linked ufsta user function in
   $UGII_USER_DIR/startup or   
   $UGII_SITE_DIR/startup or
   $UGII_VENDOR_DIR/startup directory.     
   NOTE: The user function must contain the proper extension .so, .sl or .dll
   to make ensure that it is recognized by theMenuScript.  If it does not
   have the proper extension, it will NOT berecognized by MenuScript.   
   这个比较关键,就是将生成的DLL文件放到上面的几个文件夹目录下。如果扩展名不对的话,MenuScript不能识别
   The action name you have provided in your MenuScriptmust correspond to to the dialog name provided in the action structure.  This MUST match inorder to bind your dlg file to your MenuScriptbutton.                           
   你在MenuScript中提供的action name必须与你在action structure 提供的对话框一致。
   
4) Copy yourUIStyler dialog file to the proper directory.
   All dialog files (.dlg) must be located in
      $UGII_USER_DIR/application or
      $UGII_SITE_DIR/application or
      $UGII_VENDOR_DIR/application directory
   将你的UIStylerdig文件拷贝到下面几个文件夹中。(三选一)
------------------------------------------------------------*/
#define MENUBAR_COMMENTED_OUT
#ifdef MENUBAR_COMMENTED_OUT
extern void ufsta (char *param, int *retcode, int rlen)
{
    int  error_code;
    if ( (UF_initialize()) != 0)
          return;
                                                
    if ( (error_code = UF_MB_add_styler_actions ( actions ) ) != 0 )
    {
          char fail_message[133];
         
          UF_get_fail_message(error_code,fail_message);
          printf ( "%s\n", fail_message );
    }
                                                
    UF_terminate();                             
    return;
}
#endif /*MENUBAR_COMMENTED_OUT*/
/*-------------------------------------------------------------------------*/
/*----------------------UIStyler Callback Functions ----------------------*/
/*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------
* Callback Name: DIALOG_ACCESS_apply_cb
* This is a callback function associated withan action taken from a
* UIStyler object.
*
* Input: dialog_id   -  The dialog id indicate which dialog this callback
*                        is associatedwith.  The dialog id is a dynamic,
*                        unique id and shouldnot be stored.  It is
*                        strictly for the use inthe NX Open API:
*                               UF_STYLER_ask_value(s)
*                              UF_STYLER_set_value   
*       client_data -   Client data isuser defined data associated
*                        with your dialog.  Client data may be bound
*                        to your dialog withUF_MB_add_styler_actions
*                        orUF_STYLER_create_dialog.                 
*       callback_data - This structure pointer contains information
*                        specific to the UIStylerObject type that  
*                        invoked this callbackand the callback type.
*-----------------------------------------------------------------------*/
intDIALOG_ACCESS_apply_cb ( int dialog_id,
             void * client_data,
             UF_STYLER_item_value_type_p_t callback_data)
{
     /* Makesure User Function is available. */  
     if ( UF_initialize() != 0)
          return ( UF_UI_CB_CONTINUE_DIALOG );
     /* ----Enter your callback code here ----- */
     UF_terminate ();
    /*Callback acknowledged, do not terminate dialog                 */
    /* Areturn value of UF_UI_CB_EXIT_DIALOG will not be accepted    */
    /* forthis callback type.  You must respond toyour apply button.*/
    return (UF_UI_CB_CONTINUE_DIALOG);
}
/*-------------------------------------------------------------------------
* Callback Name: DIALOG_ACCESS_back_cb
* This is a callback function associated withan action taken from a
* UIStyler object.
*
* Input: dialog_id   -  The dialog id indicate which dialog this callback
*                        is associatedwith.  The dialog id is a dynamic,
*                        unique id and shouldnot be stored.  It is
*                        strictly for the use inthe NX Open API:
*                              UF_STYLER_ask_value(s)
*                              UF_STYLER_set_value   
*       client_data -   Client data isuser defined data associated
*                        with your dialog.  Client data may be bound
*                        to your dialog withUF_MB_add_styler_actions
*                        orUF_STYLER_create_dialog.                 
*       callback_data - This structure pointer contains information
*                       specific to the UIStylerObject type that  
*                        invoked this callbackand the callback type.
*-----------------------------------------------------------------------*/
intDIALOG_ACCESS_back_cb ( int dialog_id,
             void * client_data,
             UF_STYLER_item_value_type_p_t callback_data)
{
     /* Makesure User Function is available. */  
     if ( UF_initialize() != 0)
          return ( UF_UI_CB_CONTINUE_DIALOG );
     /* ----Enter your callback code here ----- */
     uc1601("Helloboyyouwill exit this dialog!",1);
     UF_terminate ();
    /*Callback acknowledged, terminate dialog.            */
    /* It isSTRONGLY recommended that you exit your      */
    /*callback with UF_UI_CB_EXIT_DIALOG in a back call   */
    /* backrather than UF_UI_CB_CONTINUE_DIALOG.         */
    return (UF_UI_CB_EXIT_DIALOG);
}
/*-------------------------------------------------------------------------
* Callback Name: DIALOG_ACCESS_action_3_act_cb
* This is a callback function associated withan action taken from a
* UIStyler object.
*
* Input: dialog_id   -  The dialog id indicate which dialog this callback
*                        is associatedwith.  The dialog id is a dynamic,
*                        unique id and should not be stored.  It is
*                        strictly for the use inthe NX Open API:
*                              UF_STYLER_ask_value(s)
*                              UF_STYLER_set_value   
*       client_data -   Client data isuser defined data associated
*                        with your dialog.  Client data may be bound
*                        to your dialog withUF_MB_add_styler_actions
*                        or UF_STYLER_create_dialog.                 
*       callback_data - This structure pointer contains information
*                        specific to theUIStyler Object type that  
*                        invoked this callbackand the callback type.
* -----------------------------------------------------------------------*/
intDIALOG_ACCESS_action_3_act_cb ( int dialog_id,
             void * client_data,
             UF_STYLER_item_value_type_p_t callback_data)
{
     /* Makesure User Function is available. */  
     if ( UF_initialize() != 0)
          return ( UF_UI_CB_CONTINUE_DIALOG );
     /* ----Enter your callback code here ----- */
    UF_STYLER_item_value_type_t data[3];
    char info[100];
    data[0].item_attr=UF_STYLER_VALUE;
    data[0].item_id=DIALOG_ACCESS_INTEGER;
    UF_STYLER_ask_value(dialog_id,&data[0]);
    data[1].item_attr=UF_STYLER_VALUE;
    data[1].item_id=DIALOG_ACCESS_REAL;
    UF_STYLER_ask_value(dialog_id,&data[1]);
    data[2].item_attr=UF_STYLER_VALUE;
    data[2].item_id=DIALOG_ACCESS_STRING;
    UF_STYLER_ask_value(dialog_id,&data[2]);
    //将格式化的数据写入字符缓冲区
    sprintf(info,"整数为:%d\n实数为:%f\n字符串为:%s\n",data[0].value.integer,data[1].value.real,data[2].value.string);
    uc1601(info,1);
     UF_terminate ();
    /*Callback acknowledged, do not terminate dialog */
    return (UF_UI_CB_CONTINUE_DIALOG);
   
    /* orCallback acknowledged, terminate dialog.   */
    /*return ( UF_UI_CB_EXIT_DIALOG );              */
}
效果图


一键复制代码
  1. /* These includefiles are needed for the following template code.            */
  2. #include <stdio.h>
  3. #include <uf.h>
  4. #include <uf_defs.h>
  5. #include <uf_exit.h>
  6. #include <uf_ui.h>
  7. #include <uf_styler.h>
  8. #include <uf_mb.h>
  9. #include "access_dialog.h"
  10. /* The followingdefinition defines the number of callback entries */
  11. /* in the callbackstructure:                                     */
  12. /*UF_STYLER_callback_info_t DIALOG_ACCESS_cbs */
  13. #define DIALOG_ACCESS_CB_COUNT ( 3 + 1) /* Add 1 for the terminator */
  14. /*--------------------------------------------------------------------------
  15. The followingstructure defines the callback entries used by the      
  16. styler file.  This structure MUST be passed into the userfunction,   
  17. UF_STYLER_create_dialogalong with DIALOG_ACCESS_CB_COUNT.                       
  18. --------------------------------------------------------------------------*/
  19. static UF_STYLER_callback_info_tDIALOG_ACCESS_cbs[DIALOG_ACCESS_CB_COUNT] =
  20. {
  21. {UF_STYLER_DIALOG_INDEX, UF_STYLER_APPLY_CB        , 0,DIALOG_ACCESS_apply_cb},
  22. {UF_STYLER_DIALOG_INDEX, UF_STYLER_BACK_CB         , 0,DIALOG_ACCESS_back_cb},
  23. {DIALOG_ACCESS_BUTTON  , UF_STYLER_ACTIVATE_CB     , 0,DIALOG_ACCESS_action_3_act_cb},
  24. {UF_STYLER_NULL_OBJECT, UF_STYLER_NO_CB, 0, 0 }
  25. };
  26. /*--------------------------------------------------------------------------
  27. UF_MB_styler_actions_tcontains 4 fields.  These are defined asfollows:
  28. Field 1 : the nameof your dialog that you wish to display.
  29. Field 2 : any clientdata you wish to pass to your callbacks.
  30. Field 3 : yourcallback structure.
  31. Field 4 : flag toinform menubar of your dialog location. This flag MUST match the resource set in your dialog!  Do NOT ASSUME that changing this field willupdate the location of your dialog. Please use the UIStyler to indicate the position of your dialog.
  32. --------------------------------------------------------------------------*/
  33. static UF_MB_styler_actions_tactions[] = {
  34.     { "access_dialog.dlg",  NULL,   DIALOG_ACCESS_cbs,  UF_MB_STYLER_IS_NOT_TOP },
  35.     { NULL,  NULL,  NULL,  0 } /* Thisis a NULL terminated list */
  36. };
  37. /*----------------MENUBAR HOOKUP HELP Example -------------------
  38. To launch thisdialog from a Unigraphics menubar, you must follow
  39. the steps below.
  40. 1)  Add the following lines to your MenuScriptfile in order to associate a menu bar button with your dialog.  In this example, a cascade menu will becreated and will be located just before the Help button on the main menubar. Thebutton, ACCESS_DIALOG_BTN is set up to launch your dialog and will bepositioned as the first button on your pulldown menu.If you wish to add thebutton to an existing cascade, simply add the 3 lines between MENULAUNCH_CASCADE and END_OF_MENU  to yourmenuscript file.  
  41.     增加以下几行到你的MenuScript文件中用以链接菜单栏按钮和对话框。在这个例子中,一个层叠菜单将会在主菜单栏的HELP选项前创建。该按钮,ACCESS_DIALOG_BTN 是设置起来用以触发你的对话框并且将会出现在第一个下拉菜单按钮中。如果你希望增加该按钮到你现有的层叠菜单里,仅需要增加 MENU LAUNCH_CASCADE 和 END_OF_MENU之间的三行到你的Menuscript文件中。
  42.     The MenuScript file requires an extension of".men".
  43.     Make sure that you add the extension to thefile and place the file in your startup directory:
  44.       $UGII_USER_DIR/startup or
  45.       $UGII_SITE_DIR/startup or
  46.       $UGII_VENDOR_DIR/startup directory
  47.    MenuScript 文件需要以.men作为扩展名,确保你将该文件的扩展名改成.men,并将该文件下放到以下的目录中去。(注意:三选一)
  48.     Move the contents between the dashed linesto your Menuscript file.
  49. !  ----------------------------------------------------------------
  50. VERSION120
  51. 菜单脚本的版本号,在系统菜单文件、用户文件中,无论是编辑模式还是创建模式,第一行通常就是版本号说明。但是版本号,为啥是120?
  52. EDITUG_GATEWAY_MAIN_MENUBAR
  53. EDIT 编辑模式菜单文件的标志,编辑的对象应该是已经创建好的菜单,在关键字EDIT之后指出所编辑菜单的标示符,用户的菜单尽量采用编辑模式。
  54. BEFOREUG_HELP
  55. BEFORE 在已有的菜单文件中定义的某个菜单项之前加上一个新项。 这里是UG_HELP,相对应的,也有AFTER,之后都要用END_OF_BEFORE or END_OF_AFTER来结束。
  56.       CASCADE_BUTTON UISTYLER_DLG_CASCADE_BTN
  57. CASCADE_BUTTON  层叠菜单项。当它激活时打开一个子菜单,每一个级联按钮的定义,必须用MENU定义相同的菜单名。这个从下面的可以看出来。子菜单既可以在级联按钮前定义,也可以在级联按钮菜单后定义。
  58.       LABEL Dialog Launcher
  59. Label 菜单项名称,也就是我们看到的名称。
  60.     END_OF_BEFORE
  61.     MENU UISTYLER_DLG_CASCADE_BTN   前面提到过了,名字要对应
  62.       BUTTON ACCESS_DIALOG_BTN        BUTTON 是在菜单栏中添加一个项,如果有两个项,就在ACTIONS 后面再加一个BUTTON。
  63.       LABEL Display access_dialog dialog
  64.       ACTIONS access_dialog.dlg   ACTIONS表面你要执行的动作,可以有:NX系统定义的标准命令、用户定义的回调函数、一个对话框文件名称,一个GRIP程序、一个工具栏文件、操作系统的命令以及OPEN C and C++ Program的程序名称。
  65.     END_OF_MENU   非顶层菜单定义结束
  66. !  ---------------------------------------------------------------
  67. 上面这些就是下拉菜单的代码。因为我的UG是中文版的,所以加载后Dialog Launcher直接就被转换成了启动对话框,下拉菜单中的Display access_dialogdialog还是保持英文的状态。
  68. 2) Issue a call tothe function, UF_MB_add_styler_actions from the ufsta
  69.    user exit as shown below.  To use this call, remove the conditional
  70.    definitions: #ifdef MENUBAR_COMMENTED_OUT
  71.                  #endif MENUBAR_COMMENTED_OUT
  72.    如下所示,从ufstauser exit 发出调用 UF_MB_add_styler_actions请求。(这个翻译我不是很确定。)
  73.    要调用这一段函数,需要去除条件定义。
  74.    The static structure, actions, will allowyou to associate ALL of your
  75. dialogs and callback functions to the  menubar at once.  For example, if you wish to have 10 dialogsassociated to 10 different buttons on the menubar,you may enter each dialog andcallback list into the actions structure. Make sure that you have created a corresponding button in your MenuScript file.
  76.    Static structure,actions将会允许你在下拉菜单中链接所有你的对话框和回调函数。比如,如果你想让
  77.    十个对话框和十个不同的下拉菜单中的按钮一一对应的话,你需要将每一个对话框和回调列表(list)到你的actions
  78.    structure 中去。确保你已经在MenuScript文件中创建一个响应按钮。
  79.    You may also have separate shared libraries,each with a ufsta user exit
  80.    for each individual dialog.
  81. 3) Place yourcompiled and linked ufsta user function in
  82.    $UGII_USER_DIR/startup or   
  83.    $UGII_SITE_DIR/startup or
  84.    $UGII_VENDOR_DIR/startup directory.     
  85.    NOTE: The user function must contain the proper extension .so, .sl or .dll
  86.    to make ensure that it is recognized by theMenuScript.  If it does not
  87.    have the proper extension, it will NOT berecognized by MenuScript.   
  88.    这个比较关键,就是将生成的DLL文件放到上面的几个文件夹目录下。如果扩展名不对的话,MenuScript不能识别
  89.    The action name you have provided in your MenuScriptmust correspond to to the dialog name provided in the action structure.  This MUST match inorder to bind your dlg file to your MenuScriptbutton.                           
  90.    你在MenuScript中提供的action name必须与你在action structure 提供的对话框一致。
  91.    
  92. 4) Copy yourUIStyler dialog file to the proper directory.
  93.    All dialog files (.dlg) must be located in
  94.       $UGII_USER_DIR/application or
  95.       $UGII_SITE_DIR/application or
  96.       $UGII_VENDOR_DIR/application directory
  97.    将你的UIStyler的dig文件拷贝到下面几个文件夹中。(三选一)
  98. ------------------------------------------------------------*/
  99. #define MENUBAR_COMMENTED_OUT
  100. #ifdef MENUBAR_COMMENTED_OUT
  101. extern void ufsta (char *param, int *retcode, int rlen)
  102. {
  103.     int  error_code;
  104.     if ( (UF_initialize()) != 0)
  105.           return;
  106.                                                 
  107.     if ( (error_code = UF_MB_add_styler_actions ( actions ) ) != 0 )
  108.     {
  109.           char fail_message[133];
  110.          
  111.           UF_get_fail_message(error_code,fail_message);
  112.           printf ( "%s\n", fail_message );
  113.     }
  114.                                                 
  115.     UF_terminate();                             
  116.     return;
  117. }
  118. #endif /*MENUBAR_COMMENTED_OUT*/
  119. /*-------------------------------------------------------------------------*/
  120. /*----------------------UIStyler Callback Functions ----------------------*/
  121. /*-------------------------------------------------------------------------*/
  122. /*-------------------------------------------------------------------------
  123. * Callback Name: DIALOG_ACCESS_apply_cb
  124. * This is a callback function associated withan action taken from a
  125. * UIStyler object.
  126. *
  127. * Input: dialog_id   -  The dialog id indicate which dialog this callback
  128. *                        is associatedwith.  The dialog id is a dynamic,
  129. *                        unique id and shouldnot be stored.  It is
  130. *                        strictly for the use inthe NX Open API:
  131. *                               UF_STYLER_ask_value(s)
  132. *                              UF_STYLER_set_value   
  133. *       client_data -   Client data isuser defined data associated
  134. *                        with your dialog.  Client data may be bound
  135. *                        to your dialog withUF_MB_add_styler_actions
  136. *                        orUF_STYLER_create_dialog.                 
  137. *       callback_data - This structure pointer contains information
  138. *                        specific to the UIStylerObject type that  
  139. *                        invoked this callbackand the callback type.
  140. *-----------------------------------------------------------------------*/
  141. intDIALOG_ACCESS_apply_cb ( int dialog_id,
  142.              void * client_data,
  143.              UF_STYLER_item_value_type_p_t callback_data)
  144. {
  145.      /* Makesure User Function is available. */  
  146.      if ( UF_initialize() != 0)
  147.           return ( UF_UI_CB_CONTINUE_DIALOG );
  148.      /* ----Enter your callback code here ----- */
  149.      UF_terminate ();
  150.     /*Callback acknowledged, do not terminate dialog                 */
  151.     /* Areturn value of UF_UI_CB_EXIT_DIALOG will not be accepted    */
  152.     /* forthis callback type.  You must respond toyour apply button.*/
  153.     return (UF_UI_CB_CONTINUE_DIALOG);
  154. }
  155. /*-------------------------------------------------------------------------
  156. * Callback Name: DIALOG_ACCESS_back_cb
  157. * This is a callback function associated withan action taken from a
  158. * UIStyler object.
  159. *
  160. * Input: dialog_id   -  The dialog id indicate which dialog this callback
  161. *                        is associatedwith.  The dialog id is a dynamic,
  162. *                        unique id and shouldnot be stored.  It is
  163. *                        strictly for the use inthe NX Open API:
  164. *                              UF_STYLER_ask_value(s)
  165. *                              UF_STYLER_set_value   
  166. *       client_data -   Client data isuser defined data associated
  167. *                        with your dialog.  Client data may be bound
  168. *                        to your dialog withUF_MB_add_styler_actions
  169. *                        orUF_STYLER_create_dialog.                 
  170. *       callback_data - This structure pointer contains information
  171. *                       specific to the UIStylerObject type that  
  172. *                        invoked this callbackand the callback type.
  173. *-----------------------------------------------------------------------*/
  174. intDIALOG_ACCESS_back_cb ( int dialog_id,
  175.              void * client_data,
  176.              UF_STYLER_item_value_type_p_t callback_data)
  177. {
  178.      /* Makesure User Function is available. */  
  179.      if ( UF_initialize() != 0)
  180.           return ( UF_UI_CB_CONTINUE_DIALOG );
  181.      /* ----Enter your callback code here ----- */
  182.      uc1601("Hello,boy,youwill exit this dialog!",1);
  183.      UF_terminate ();
  184.     /*Callback acknowledged, terminate dialog.            */
  185.     /* It isSTRONGLY recommended that you exit your      */
  186.     /*callback with UF_UI_CB_EXIT_DIALOG in a back call   */
  187.     /* backrather than UF_UI_CB_CONTINUE_DIALOG.         */
  188.     return (UF_UI_CB_EXIT_DIALOG);
  189. }
  190. /*-------------------------------------------------------------------------
  191. * Callback Name: DIALOG_ACCESS_action_3_act_cb
  192. * This is a callback function associated withan action taken from a
  193. * UIStyler object.
  194. *
  195. * Input: dialog_id   -  The dialog id indicate which dialog this callback
  196. *                        is associatedwith.  The dialog id is a dynamic,
  197. *                        unique id and should not be stored.  It is
  198. *                        strictly for the use inthe NX Open API:
  199. *                              UF_STYLER_ask_value(s)
  200. *                              UF_STYLER_set_value   
  201. *       client_data -   Client data isuser defined data associated
  202. *                        with your dialog.  Client data may be bound
  203. *                        to your dialog withUF_MB_add_styler_actions
  204. *                        or UF_STYLER_create_dialog.                 
  205. *       callback_data - This structure pointer contains information
  206. *                        specific to theUIStyler Object type that  
  207. *                        invoked this callbackand the callback type.
  208. * -----------------------------------------------------------------------*/
  209. intDIALOG_ACCESS_action_3_act_cb ( int dialog_id,
  210.              void * client_data,
  211.              UF_STYLER_item_value_type_p_t callback_data)
  212. {
  213.      /* Makesure User Function is available. */  
  214.      if ( UF_initialize() != 0)
  215.           return ( UF_UI_CB_CONTINUE_DIALOG );
  216.      /* ----Enter your callback code here ----- */
  217.     UF_STYLER_item_value_type_t data[3];
  218.     char info[100];
  219.     data[0].item_attr=UF_STYLER_VALUE;
  220.     data[0].item_id=DIALOG_ACCESS_INTEGER;
  221.     UF_STYLER_ask_value(dialog_id,&data[0]);
  222.     data[1].item_attr=UF_STYLER_VALUE;
  223.     data[1].item_id=DIALOG_ACCESS_REAL;
  224.     UF_STYLER_ask_value(dialog_id,&data[1]);
  225.     data[2].item_attr=UF_STYLER_VALUE;
  226.     data[2].item_id=DIALOG_ACCESS_STRING;
  227.     UF_STYLER_ask_value(dialog_id,&data[2]);
  228.     //将格式化的数据写入字符缓冲区
  229.     sprintf(info,"整数为:%d\n实数为:%f\n字符串为:%s\n",data[0].value.integer,data[1].value.real,data[2].value.string);
  230.     uc1601(info,1);
  231.      UF_terminate ();
  232.     /*Callback acknowledged, do not terminate dialog */
  233.     return (UF_UI_CB_CONTINUE_DIALOG);
  234.    
  235.     /* orCallback acknowledged, terminate dialog.   */
  236.     /*return ( UF_UI_CB_EXIT_DIALOG );              */
  237. }
复制代码


评分

参与人数 2U币 +10 G币 +51 元宝 +2 收起 理由
逐梦的蜗牛 + 1 不错,支持你!
副总经理 + 10 + 50 + 2 不错,支持!

查看全部评分

有奖推广贴子: 

回复

使用道具 举报

三级士官

Rank: 3Rank: 3

11

主题

54

帖子

641

积分
推荐
 楼主| 发表于 2015-3-25 12:44:38 | 只看该作者
请叫我老师头 发表于 2015-3-25 11:24
谢谢楼主,辛苦!

分享了自己也能进步
回复 支持 1 反对 0

使用道具 举报

爱好者终身VIP

Rank: 11Rank: 11Rank: 11Rank: 11

19

主题

350

帖子

3022

积分

VIP会员活跃会员

沙发
发表于 2015-3-25 11:24:58 | 只看该作者
谢谢楼主,辛苦!
回复 支持 反对

使用道具 举报

六级士官

Rank: 4

10

主题

132

帖子

1412

积分
板凳
发表于 2015-3-25 11:41:59 | 只看该作者
想看懂还是很吃力!可能个人层次还没达到
回复 支持 反对

使用道具 举报

三级士官

Rank: 3Rank: 3

11

主题

54

帖子

641

积分
5#
 楼主| 发表于 2015-3-25 12:45:28 | 只看该作者
~嘁哩喀喳 发表于 2015-3-25 11:41
想看懂还是很吃力!可能个人层次还没达到

恩,多多看可能就会好一点,特别是那些英文的说明,第一次根本不想看,但是看了两次,其实大部分还是能看懂的
回复 支持 反对

使用道具 举报

Administrator

德高才能望重

Rank: 16Rank: 16Rank: 16Rank: 16

2295

主题

1万

帖子

3万

积分

站长优秀版主论坛技术员论坛元老论坛贡献推广达人

6#
发表于 2015-3-25 14:18:50 | 只看该作者
不是搞这个的表示看不懂, 学习了。
回复 支持 反对

使用道具 举报

六级士官

Rank: 4

10

主题

132

帖子

1412

积分
7#
发表于 2015-3-25 15:07:55 | 只看该作者
老叶 发表于 2015-3-25 14:18
不是搞这个的表示看不懂, 学习了。

其实关于二次开发, 这方面的资料还是很头疼
回复 支持 反对

使用道具 举报

六级士官

Rank: 4

10

主题

132

帖子

1412

积分
8#
发表于 2015-3-25 15:17:02 | 只看该作者
奇塔加个QQ吧78780640 想跟你共同进步
回复 支持 反对

使用道具 举报

三级士官

Rank: 3Rank: 3

11

主题

54

帖子

641

积分
9#
 楼主| 发表于 2015-3-25 15:50:15 | 只看该作者
老叶 发表于 2015-3-25 14:18
不是搞这个的表示看不懂, 学习了。

谢谢老叶一直支持我
回复 支持 反对

使用道具 举报

三级士官

Rank: 3Rank: 3

11

主题

54

帖子

641

积分
10#
 楼主| 发表于 2015-3-25 15:50:37 | 只看该作者
~嘁哩喀喳 发表于 2015-3-25 15:17
奇塔加个QQ吧78780640 想跟你共同进步

好的,不过我是小白,你不要介意
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

 
 
QQ:1359218528
工作时间:
9:00-17:00
 
微信公众号
手机APP
机械社区
微信小程序

手机版|UG爱好者论坛 ( 京ICP备10217105号-2 )    论坛管理员QQ:1359218528

本站信息均由会员发表,不代表本网站立场,如侵犯了您的权利请联系管理员,邮箱:1359218528@qq.com  

Powered by UG爱好者 X3.2  © 2001-2014 Comsenz Inc. GMT+8, 2024-5-2 12:29

返回顶部