lcfq wrote:
我设计了一个对话框,意图是:根据MENUOPTION1中的index来动态地设置MENUOPTION2中显示的内容。在编译时提示MENUOPTION2中的strings没有初始化。请教各位高手该如何解决?程序如下:
int TYPE_dalei_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]={"a1","a2"};
char xiaolei_opt2[2][20]={"a3","a4"};
char xiaolei_opt3[2][20]={"a5","a6"};
int row_num;
row_num=2;
/* Make sure User Function is available. */
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
//get the index of the dalei option menu.
item1_data.item_attr=UF_STYLER_VALUE;
item1_data.item_id=TYPE_DALEI_OPTION;
item1_data.indicator=UF_STYLER_INTEGER_VALUE;
UF_STYLER_ask_value(dialog_id, [$item1_data)]
index=item1_data.value.integer;
//according to the index value to change the text of the xiaolei option menu.
//item2_data.indicator=UF_STYLER_STRING_PTR_VALUE;
item2_data.value.strings=xiaolei_opt1;
if(index!=0)
{
if(index==1)
{
item2_data.value.strings=xiaolei_opt2;
}
else
{
item2_data.value.strings=xiaolei_opt3; }
}
item2_data.item_attr=UF_STYLER_SUBITEM_VALUES;
item2_data.item_id=TYPE_XIAOLEI_OPTION;
item2_data.count=row_num;
UF_STYLER_set_value(dialog_id, [$item2_data)]
/* else
{
item2_data.value.strings[0]=xiaolei_opt[0];
item2_data.value.strings[1]=xiaolei_opt[1];
}
*/
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 ); */
}
编译提示:warning C4700: local variable 'item2_data' used without having been initialized。
wlzhao33 wrote:
把item2_data.value.strings=xiaolei_opt1;改为item2_data.value.strings=(char **)xiaolei_opt1;试试。好像以前我和另外一个斑竹讨论过这个问题,这儿应该有这个帖子,你自己找找看,应该没问题。
欢迎光临 iCAx开思工具箱 (https://t.icax.org/) | Powered by Discuz! X3.3 |