wlzhao33 wrote:
把item2_data.value.strings=xiaolei_opt1;改为item2_data.value.strings=(char **)xiaolei_opt1;试试。好像以前我和另外一个斑竹讨论过这个问题,这儿应该有这个帖子,你自己找找看,应该没问题。
我照你的提示作了一下,编译时没有错误提示,但是在ug中对话框的值却不随选项变化。我的代码如下,能否麻烦你看看?谢谢。
int CHANGE_da_index_cb ( int dialog_id,
void * client_data,
UF_STYLER_item_value_type_p_t callback_data)
{
UF_STYLER_item_value_type_t item1_data,item2_data;
int index;
char xiaolei_opt1[2][20]={"d1","d2"};
char xiaolei_opt2[2][20]={"b1","b2"};
char xiaolei_opt3[2][20]={"c1","c2"};
int row_num=2;
char msg[133];
char buffer[10];
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
item1_data.item_attr=UF_STYLER_VALUE;
item1_data.item_id=CHANGE_OPTION_0;
//item1_data.indicator=UF_STYLER_INTEGER_VALUE;
UF_STYLER_ask_value(dialog_id, [$item1_data)]
index=item1_data.value.integer;
strcpy(msg, "current index is:");
_itoa(index, buffer,2);
strcat(msg,buffer);
uc1601(msg,1);
item2_data.item_attr=UF_STYLER_SUBITEM_VALUES;
item2_data.item_id=CHANGE_OPTION_1;
item2_data.count=row_num;
item2_data.value.strings=xiaolei_opt1;
// item2_data.value.strings[1]=xiaolei_opt[1];
if(index!=0)
{
if(index==1)
{
item2_data.value.strings=(char **)xiaolei_opt2;
}
else
{
item2_data.value.strings=(char **)xiaolei_opt3;
}
}
UF_STYLER_set_value(dialog_id, [$item2_data)]
UF_terminate ();
/* Callback acknowledged, do not terminate dialog */
return (UF_UI_CB_CONTINUE_DIALOG);
/* or Callback acknowledged, terminate dialog. */
/* return ( UF_UI_CB_EXIT_DIALOG ); */
} |