PLM之家PLMHome-国产软件践行者

[解决] 用UF_UI_create_filebox()时UG崩溃了

  [复制链接]

2015-5-5 08:36:17 4708 4

文星和合 发表于 2015-5-1 11:53:07 |阅读模式

文星和合 楼主

2015-5-1 11:53:07

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x

' v& b- _8 q/ u, y; h3 F. e+ l0 [/*****************************************************************************
6 K# P6 p$ s" A0 n**
& x  k' t6 z& h. T' R** createfilebox.cpp
7 f2 d# R4 Y, @& [**. X6 p9 K5 D, H* d" }
** Description:) w7 d# G; j5 a  w# x
**     Contains Unigraphics entry points for the application.
6 w0 b' c: D! y+ D0 L; t+ `% [+ N**
' |: N2 `6 K  v% p, f* B) ~*****************************************************************************/
7 v. |3 z* J1 n6 m& y2 a+ Z/* Include files */
9 |$ |' Y; X4 o# ?#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
3 x3 X  Z! S5 D% U5 d#   include <strstream>9 w) [& I( H: |4 b
#   include <iostream>
8 ?/ g; V. E' I. {    using std:strstream;
' Z# w: v. _+ X    using std::endl;   
% ~5 F9 N2 M/ j. ?+ C8 j    using std::ends;% ?, C+ r! n! k4 g1 A
    using std::cerr;+ }/ k5 F3 t$ W3 j3 r) d4 j
#else
3 B, a. y. t  H( l& H! H#   include <strstream.h>( W+ [# u% `' i/ \0 G6 ?
#   include <iostream.h>2 {  l$ J. H2 E5 ]/ g6 E& ]
#endif& H) n# V+ E) z# r% s9 v% X1 u9 _
#include <uf.h>6 }  w* o& a8 |  s( P, W+ a  p
#include <uf_ui.h>1 _8 |# O4 M6 o  X
#include <uf_exit.h>8 ~- w. J0 R) E4 h6 @: g7 G
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
9 R/ M9 X- ~. S8 z6 d# a) L8 Nstatic int report_error( char *file, int line, char *call, int irc)
2 A/ z; q# d5 ]' j- ^{
, V( p1 |9 m' F1 }- K9 q    if (irc)
6 V* W, D5 G3 e: p) S    {7 o8 q" G  q2 P+ j& U6 D
        char err[133],5 ]+ `( _& ?: B# J8 C$ m. j, f* P
             msg[133];
1 v2 k+ P- \& {- f/ g& l& j; f        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",+ \/ G! Y' O6 L7 T3 ~/ v9 t8 I% y6 [
            irc, line, file);
/ v) Y+ e) B2 D. [, x5 A        UF_get_fail_message(irc, err);
: d, n) Z3 S" v$ x/ d* R        UF_print_syslog(msg, FALSE);1 K, g, @/ A* m8 k
        UF_print_syslog(err, FALSE);( G+ W) N6 q: R& B
        UF_print_syslog("\n", FALSE);
/ f# b# s' n8 R4 x* K4 i# ]        UF_print_syslog(call, FALSE);
2 D! z) Y# N8 m4 o0 E5 |3 i! l4 L        UF_print_syslog(";\n", FALSE);( s+ y" s* ^& R4 Y3 l% j& O' D  K
        if (!UF_UI_open_listing_window())
" A; ]8 V- f+ V' h0 I% g* Y3 g        {
4 J. x2 o2 `$ H4 \! u" Z            UF_UI_write_listing_window(msg);4 U: n! V  U" l9 _
            UF_UI_write_listing_window(err);* L' K% ?" k9 L1 |& s4 i  ~1 o5 t
            UF_UI_write_listing_window("\n");% q) Q/ Q6 u1 P3 i  C4 @: N, F
            UF_UI_write_listing_window(call);
+ ~( u' |) y; O# z$ ~5 F            UF_UI_write_listing_window(";\n");
$ u- |) B! w9 t2 t2 [' y        }/ e. y( b; E* z  a7 e
    }
7 n" W1 n, n1 k2 g7 q& Z- }    return(irc);( e# _. O( N* T4 Z" ?5 C( H! R, j1 n$ o0 A
}$ n8 D, D. b6 e+ w

7 Q; j" R! z& M; V5 P) s7 c/*****************************************************************************" U& ~, {9 O& Z, l  a
**  Activation Methods
, l, k6 B6 \& u! H$ K*****************************************************************************/4 A7 n/ F3 O2 Z& E7 W) ?
/*  Explicit Activation/ @% m! t; Q/ n( p, E# |
**      This entry point is used to activate the application explicitly, as in9 b6 s- ^" V6 W7 @) Q
**      "File->Execute UG/Open->User Function..." */
5 n1 d  Y; ?' {4 [extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
0 R( Y) o/ k+ a6 H8 K; c" ^  S1 j{
" k" G% _/ {/ ?/ d0 e/ ~$ K7 L* ^    /* Initialize the API environment */+ T5 A- b* S5 s7 d
char prompt_string[]="open file";  U; V0 z7 \$ H  {; K, M: N
char title_string[] = "select file";% V* n$ T7 T: B" H  k: L. T& w
char filter_string[] = "*.prt";
/ x; }( t* k8 X# e% @) J" _  O char default_name[] = "my file";: b  L+ W2 q- p" m2 q; |
char filename[256];
6 `9 v& ]8 D/ a0 Z+ q int response;
0 ?8 F( b" u) z7 Q7 u2 A( O) |    if( UF_CALL(UF_initialize()) ) " m: E' Q# w& i, Y' C- P
    {
) b/ [' N& }, |        /* Failed to initialize */9 _" o0 y8 B! t( m; Y
        return;
+ f" x3 F* z+ l" v& g    }
8 R3 h' W' [# }% d; |& [1 |    . c* z$ `  |: ~& b: c$ W7 C; t
    /* TODO: Add your application code here */
' U, T- r, D3 y" \ UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
6 m  y6 t0 k! y# S. O    /* Terminate the API environment *// g3 X0 |# u3 {
    UF_CALL(UF_terminate());- @: v2 W6 H) c9 Q6 {7 z
}7 w# X4 {# ]* q: u- b/ R, D
/*****************************************************************************
4 ?: S) u( Y9 }, v& X* o0 f**  Utilities! F* k5 ^; i% r: o- z3 ?$ ^
*****************************************************************************/) a; f! a2 W( \9 l$ B* y; P
/* Unload Handler
5 }1 e( Y% I/ r' p: @3 w0 i**     This function specifies when to unload your application from Unigraphics.3 w$ w) J; |. f6 F# {2 a, z
**     If your application registers a callback (from a MenuScript item or a* S" S+ A+ d7 O" Y
**     User Defined Object for example), this function MUST return8 P7 O" A& s8 K1 ^+ E' U$ F6 y7 Q; z
**     "UF_UNLOAD_UG_TERMINATE". */
$ Z; G0 t# @; s* V; p4 wextern int ufusr_ask_unload( void )
7 |# U! W  l% i{5 s- B" M/ X% X3 }" R  M8 @* h
    return( UF_UNLOAD_IMMEDIATELY );8 j9 }, N2 n7 F0 s2 u6 m8 j5 U% {/ N: O
}
7 Y* @- F% k6 \0 h0 U9 t% K3 x: X! M4 [" S
CreateFilebox.png
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

全部回复4

mildcat 发表于 2015-5-2 20:07:06

mildcat 沙发

2015-5-2 20:07:06

UF_UI_create_filebox 我没有试你这个
9 T8 o1 f4 ]8 e1 V6 C! d8 Y. P8 u8 }9 u0 x6 H
不过你加个uf_call或者看下syslog 啥问题
! o  h$ x$ F9 |. \3 U
4 I( y; F9 h0 `; w0 M
该会员没有填写今日想说内容.
回复 支持 反对

使用道具 举报

文星和合 发表于 2015-5-2 20:18:39

文星和合 板凳

2015-5-2 20:18:39

mildcat 发表于 2015-5-2 20:07
0 g% G2 I" \) |/ L7 z4 BUF_UI_create_filebox 我没有试你这个
& G) K% N) ]5 f# s9 d& O
/ `; M3 y8 S3 V, T$ t% q不过你加个uf_call或者看下syslog 啥问题
3 S# x& E7 ]  o! a% E- {- d
UF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。
( ]" W$ l; X! i7 T. ?, b我想用UF_UI_create_filebox()创建一个打开文件的对话框。UG有别的函数可以创建打开文件的对话框?
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

简简单单 发表于 2015-5-5 08:31:59

简简单单 地板

2015-5-5 08:31:59

文星和合 发表于 2015-5-2 20:18. e$ i( H# N' k3 H5 c! K! O; q
UF_CALL没有报错。打开文件的对话框也生成了。就是在点击ok之后,UG崩掉了。
: e4 p4 f7 W+ |& Y; c我想用UF_UI_create_filebox ...
, ]8 @# i0 L9 M0 d. _7 b0 r6 B

" ]' f# g' z, b. X  }# w#include <uf.h>  Z* y4 N+ A' q7 L. U4 j1 B
#include <uf_ui.h>6 c+ L/ ~, E3 M
#include <uf_exit.h>
0 a8 |0 [% X1 y( T" @2 sextern DllExport void ufusr( char *parm, int *returnCode, int rlen )
$ O5 i/ b! |6 b+ p7 E2 ^! x{8 |4 e: J; n5 J* i
        /* Initialize the API environment */9 n* k  [; [( M+ c5 p, m+ U
        char *prompt_string="输入文件名";
7 \: ]' E( d$ I9 k        char *title_string = "另存为";4 h! B: m: ]  T5 B1 @  D- w0 R
        char *filter_string = "E:\\+*.prt";: v2 m0 K. K9 F. ]8 M; d0 q2 H8 m
        char *default_name = "OK-PRT";+ f. U  Y1 _! h
        char filename[256];: c# b- g( H. ^0 H
        int response;
2 E- [9 B9 ^, o8 t# _; a        UF_initialize();
3 i$ ?" J$ E: k0 _* p        UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);
" j$ f+ H9 q9 k: A, e- c2 O+ y+ c) j        if (response ==UF_UI_OK)
, {2 z. h3 ?2 A0 C                uc1601(filename,1);2 x- m/ ~8 e6 B. ]6 O6 G* H$ ?
        else if(response ==UF_UI_CANCEL)
3 a- c' q0 P2 X$ M" E% d& u                uc1601("取消",1);: `; m8 q% q' b7 ]0 C0 @
        UF_terminate();
. B5 `0 d2 u3 G! t: u}
' {- P' _5 h+ d# }6 _' @# T9 uextern int ufusr_ask_unload( void )
: W0 h+ g2 T. X" f4 J{0 t; t% O$ I, a8 {
        return( UF_UNLOAD_IMMEDIATELY );) \2 G  i" P; J; Z6 N) z: D
}

评分

参与人数 1PLM币 +3 收起 理由
admin + 3 很给力!

查看全部评分

上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了