用UF_UI_create_filebox()时UG崩溃了
/*****************************************************************************
**
** createfilebox.cpp
**
** Description:
** Contains Unigraphics entry points for the application.
**
*****************************************************************************/
/* Include files */
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# include <strstream>
# include <iostream>
using std::ostrstream;
using std::endl;
using std::ends;
using std::cerr;
#else
# include <strstream.h>
# include <iostream.h>
#endif
#include <uf.h>
#include <uf_ui.h>
#include <uf_exit.h>
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
char err,
msg;
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
irc, line, file);
UF_get_fail_message(irc, err);
UF_print_syslog(msg, FALSE);
UF_print_syslog(err, FALSE);
UF_print_syslog("\n", FALSE);
UF_print_syslog(call, FALSE);
UF_print_syslog(";\n", FALSE);
if (!UF_UI_open_listing_window())
{
UF_UI_write_listing_window(msg);
UF_UI_write_listing_window(err);
UF_UI_write_listing_window("\n");
UF_UI_write_listing_window(call);
UF_UI_write_listing_window(";\n");
}
}
return(irc);
}
/*****************************************************************************
**Activation Methods
*****************************************************************************/
/*Explicit Activation
** This entry point is used to activate the application explicitly, as in
** "File->Execute UG/Open->User Function..." */
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
{
/* Initialize the API environment */
char prompt_string[]="open file";
char title_string[] = "select file";
char filter_string[] = "*.prt";
char default_name[] = "my file";
char filename;
int response;
if( UF_CALL(UF_initialize()) )
{
/* Failed to initialize */
return;
}
/* TODO: Add your application code here */
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
/* Terminate the API environment */
UF_CALL(UF_terminate());
}
/*****************************************************************************
**Utilities
*****************************************************************************/
/* Unload Handler
** This function specifies when to unload your application from Unigraphics.
** If your application registers a callback (from a MenuScript item or a
** User Defined Object for example), this function MUST return
** "UF_UNLOAD_UG_TERMINATE". */
extern int ufusr_ask_unload( void )
{
return( UF_UNLOAD_IMMEDIATELY );
}
UF_UI_create_filebox 我没有试你这个
不过你加个uf_call或者看下syslog 啥问题
mildcat 发表于 2015-5-2 20:07
UF_UI_create_filebox 我没有试你这个
不过你加个uf_call或者看下syslog 啥问题
UF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。
我想用UF_UI_create_filebox()创建一个打开文件的对话框。UG有别的函数可以创建打开文件的对话框? 文星和合 发表于 2015-5-2 20:18
UF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。
我想用UF_UI_create_filebox ...
#include <uf.h>
#include <uf_ui.h>
#include <uf_exit.h>
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
{
/* Initialize the API environment */
char *prompt_string="输入文件名";
char *title_string = "另存为";
char *filter_string = "E:\\+*.prt";
char *default_name = "OK-PRT";
char filename;
int response;
UF_initialize();
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);
if (response ==UF_UI_OK)
uc1601(filename,1);
else if(response ==UF_UI_CANCEL)
uc1601("取消",1);
UF_terminate();
}
extern int ufusr_ask_unload( void )
{
return( UF_UNLOAD_IMMEDIATELY );
} 图片,OK
页:
[1]