iCAx开思工具箱
标题:
请键盘兄来帮帮我
[打印本页]
作者:
njyang
时间:
2005-4-21 19:08
标题:
请键盘兄来帮帮我
在UG中有个函数UF_UI_create_filebox的最后一个参数.
int * response Output UF_UI_OK: OK was selected
UF_UI_CANCEL: CANCEL was selected
我将写入文件名后点"确定"时,生成文件,点"取消"却报错.为何?
char filter_string[132] = "*.txt";
char filename[132];
int response;
int rc = 0;
char msg[132];
FILE *fp;
if ( UF_initialize() != 0)
return ( UF_UI_CB_CONTINUE_DIALOG );
/* ---- Enter your callback code here ----- */
rc =UF_UI_create_filebox (" ",
"My dialog title",
filter_string,
"my_default_name",
filename,
[$response)]
if(rc)
{
UF_get_fail_message(rc, msg);
printf("error = %s\n", msg);
}
if((fp=fopen(filename,"w"))==NULL)
{
printf("can't open file\n\n");
exit(0);
}
fwrite(response,10,1,fp);
fclose(fp);
作者:
深夜摔键盘
时间:
2005-4-21 20:25
你没有处理response为 UF_UI_CANCEL时的情况,下面的语句要被执行的,
if((fp=fopen(filename,"w"))==NULL)
{
printf("can't open file\n\n");
exit(0);
}
你用了exit(0),这个不对,DLL只能是被卸载。另外exit是用于console程序的退出,win32只能是终止进程。
作者:
leechongqing
时间:
2005-4-27 10:19
是的,用if语句,如果是确定按钮按下,则程序往下执行,如果不是,则返回
欢迎光临 iCAx开思工具箱 (https://t.icax.org/)
Powered by Discuz! X3.3