小白学UG二次开发_UG菜单栏和UG Block编程
本例参考UG自动生成的代码文件还有《基于UG NX系统的二次开发》周临震等. 另外感谢Murry对我的帮助。以下代码由前面小白学UG二次开发_UGOpen UIStyler 对话框设计文中所举例子生成的C代码,如上例所说,该代码提供了分别由菜单栏、block和user 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_MENUto 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_HELPBEFORE 在已有的菜单文件中定义的某个菜单项之前加上一个新项。 这里是UG_HELP,相对应的,也有AFTER,之后都要用END_OF_BEFORE or END_OF_AFTER来结束。 CASCADE_BUTTON UISTYLER_DLG_CASCADE_BTN CASCADE_BUTTON层叠菜单项。当它激活时打开一个子菜单,每一个级联按钮的定义,必须用MENU定义相同的菜单名。这个从下面的可以看出来。子菜单既可以在级联按钮前定义,也可以在级联按钮菜单后定义。 LABEL Dialog LauncherLabel 菜单项名称,也就是我们看到的名称。 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 themenubar 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 将你的UIStyler的dig文件拷贝到下面几个文件夹中。(三选一) ------------------------------------------------------------*/#define MENUBAR_COMMENTED_OUT #ifdef MENUBAR_COMMENTED_OUTextern void ufsta (char *param, int *retcode, int rlen){ interror_code; if ( (UF_initialize()) != 0) return; if ( (error_code = UF_MB_add_styler_actions ( actions ) ) != 0 ) { char fail_message; 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("Hello,boy,youwill 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; char info; data.item_attr=UF_STYLER_VALUE; data.item_id=DIALOG_ACCESS_INTEGER; UF_STYLER_ask_value(dialog_id,&data); data.item_attr=UF_STYLER_VALUE; data.item_id=DIALOG_ACCESS_REAL; UF_STYLER_ask_value(dialog_id,&data); data.item_attr=UF_STYLER_VALUE; data.item_id=DIALOG_ACCESS_STRING; UF_STYLER_ask_value(dialog_id,&data); //将格式化的数据写入字符缓冲区 sprintf(info,"整数为:%d\n实数为:%f\n字符串为:%s\n",data.value.integer,data.value.real,data.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 ); */ }效果图一键复制代码:/* 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 =
{
{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_MENUto 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 themenubar 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
将你的UIStyler的dig文件拷贝到下面几个文件夹中。(三选一)
------------------------------------------------------------*/
#define MENUBAR_COMMENTED_OUT
#ifdef MENUBAR_COMMENTED_OUT
extern void ufsta (char *param, int *retcode, int rlen)
{
interror_code;
if ( (UF_initialize()) != 0)
return;
if ( (error_code = UF_MB_add_styler_actions ( actions ) ) != 0 )
{
char fail_message;
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("Hello,boy,youwill 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;
char info;
data.item_attr=UF_STYLER_VALUE;
data.item_id=DIALOG_ACCESS_INTEGER;
UF_STYLER_ask_value(dialog_id,&data);
data.item_attr=UF_STYLER_VALUE;
data.item_id=DIALOG_ACCESS_REAL;
UF_STYLER_ask_value(dialog_id,&data);
data.item_attr=UF_STYLER_VALUE;
data.item_id=DIALOG_ACCESS_STRING;
UF_STYLER_ask_value(dialog_id,&data);
//将格式化的数据写入字符缓冲区
sprintf(info,"整数为:%d\n实数为:%f\n字符串为:%s\n",data.value.integer,data.value.real,data.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 ); */
}
请叫我老师头 发表于 2015-3-25 11:24 static/image/common/back.gif
谢谢楼主,辛苦!
分享了自己也能进步 谢谢楼主,辛苦!{:hug:} 想看懂还是很吃力!可能个人层次还没达到 ~嘁哩喀喳 发表于 2015-3-25 11:41 static/image/common/back.gif
想看懂还是很吃力!可能个人层次还没达到
恩,多多看可能就会好一点,特别是那些英文的说明,第一次根本不想看,但是看了两次,其实大部分还是能看懂的 不是搞这个的表示看不懂,{:lol:} 学习了。 老叶 发表于 2015-3-25 14:18 static/image/common/back.gif
不是搞这个的表示看不懂, 学习了。
其实关于二次开发, 这方面的资料还是很头疼 奇塔加个QQ吧78780640 想跟你共同进步 老叶 发表于 2015-3-25 14:18 static/image/common/back.gif
不是搞这个的表示看不懂, 学习了。
谢谢老叶一直支持我 ~嘁哩喀喳 发表于 2015-3-25 15:17 static/image/common/back.gif
奇塔加个QQ吧78780640 想跟你共同进步
好的,不过我是小白,你不要介意
页:
[1]
2