|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
* X9 e8 w1 D! k$ C2 F0 ?. ^- i/*****************************************************************************
2 @. [, A' V2 ?3 t) ]0 G; w**% p4 M0 q6 \* d0 [* |3 u& e
** createfilebox.cpp
; z4 W1 p' {/ O0 s- j**
9 p$ v; e$ B* G C Y8 r+ w** Description:
# u' R- F h* R5 c3 _$ e5 }** Contains Unigraphics entry points for the application.
: {+ b" K! \ w8 V0 `**- _$ v: j, O& z( E6 y
*****************************************************************************/
0 s, q( y0 \: n+ i/ J! I0 Q/* Include files */' m& i. h2 K: b n; Y2 V; ^
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
; B. v2 c w! W; h8 Q# include <strstream>' e. I- z/ B6 m3 s$ e2 |+ q
# include <iostream>! e% W5 r9 N5 D8 |* E5 {
using std: strstream;& e& c P D; L5 W; I
using std::endl; 0 P; x, V3 w6 s4 Y! r
using std::ends;
) w% M- x1 s1 ^8 m0 p using std::cerr;
* S' v9 E" f6 l% E& F; n#else
1 S, M3 {3 H3 j6 v# include <strstream.h>; k# f. [; B# J! r5 c
# include <iostream.h>
; n* G' j9 { A2 @# L* x+ S8 q! M#endif
k1 i+ ^5 q, C#include <uf.h>, A: p. a7 B& P. @0 h9 m: [$ `
#include <uf_ui.h>
2 D8 R# r0 y+ b#include <uf_exit.h>: e! f6 Z( E2 L; s
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
* V9 P" X0 l. z" `: x* fstatic int report_error( char *file, int line, char *call, int irc)
9 r; D5 W) m( F' r$ p{; r9 M @/ ^! ?. y
if (irc)% {9 j, T: y$ s# x
{8 H2 b4 K- L* [' o+ b8 s8 o8 K
char err[133],
6 _2 t9 q# V" \- [) y. u) Q msg[133];* _ Y/ F, ]" t! \/ b* s; @7 {
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
- l& J( R$ Z) {) q" l irc, line, file);
- C, @! g" B& j9 I4 n UF_get_fail_message(irc, err);2 r: N5 \& Y3 M/ M0 d: z1 W+ v4 ~
UF_print_syslog(msg, FALSE);
9 r1 Q1 I) s1 m, q6 W UF_print_syslog(err, FALSE);
2 @. e. _' i: \" Q3 C4 x UF_print_syslog("\n", FALSE);5 Q9 q8 V" O8 o7 k K! }
UF_print_syslog(call, FALSE);2 p7 W; d3 o0 m4 x
UF_print_syslog(";\n", FALSE);4 I* z9 m; E6 k7 F+ f+ t: z
if (!UF_UI_open_listing_window())
* v7 V+ p3 j% \! u1 b. l! Q: w {( r6 h& t% n, R+ X$ X4 I1 {- ?
UF_UI_write_listing_window(msg);8 p% u$ ]2 e4 T( m
UF_UI_write_listing_window(err);
/ {9 {$ E7 b" n6 {. \5 W UF_UI_write_listing_window("\n");
! [8 h. m u/ y1 m; g7 [# \ UF_UI_write_listing_window(call);3 [4 ^' n2 J3 i
UF_UI_write_listing_window(";\n");
/ f0 t! H U+ c8 u } }- ~$ T* E" d# i6 e) A
}( A$ p- N9 g: C. \6 |
return(irc);
" ?! K) k/ X4 y$ h}
, E' h' {; d, G `, x4 y1 u9 o. ~% H( e) g
/*****************************************************************************
& [+ `; L2 ] p$ X0 s9 O** Activation Methods
* s. Y7 e# } ]7 B6 p4 z. R*****************************************************************************/( m6 @; i2 @8 F" |4 w
/* Explicit Activation
# m& g9 a9 n# M6 F# g** This entry point is used to activate the application explicitly, as in
+ {# t" N" b0 g k; ~, s** "File->Execute UG/Open->User Function..." */
/ l$ r5 _& p' T. k+ cextern DllExport void ufusr( char *parm, int *returnCode, int rlen )% \( h2 ^$ j: K7 o* s
{
' \. `0 D0 ^( K: }. n$ u /* Initialize the API environment */
! o9 w5 Z( z- G6 f+ _ char prompt_string[]="open file";
' h; p' a* t0 O- A' w char title_string[] = "select file"; S- W. D' g* g) X
char filter_string[] = "*.prt";7 O0 r7 I" V! x, F# ?
char default_name[] = "my file";
0 D# U8 d& v2 [# m char filename[256];
0 k1 o. m- \& y, n- n& V int response;
- n0 Q' r6 C0 }5 F/ `9 U# Z- }3 E if( UF_CALL(UF_initialize()) ) 9 s; L, K0 Z7 U0 `- G
{3 h, V2 f) t7 P+ R# F6 ^8 E7 k
/* Failed to initialize */% {, y4 Z" z9 t& S7 U
return;
# M; A& @5 y) @. W# P$ f }8 l r. y+ y8 f! `. [+ S
/ M" q4 C# |9 v9 b. x
/* TODO: Add your application code here */# e$ D! K+ j$ B! r
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
! s9 z+ h: W) [9 C+ A /* Terminate the API environment */
, Z9 E1 z2 [: q, B6 a UF_CALL(UF_terminate());
' ?3 r2 V7 ?7 R$ C4 K Z}
: s$ k3 k% n+ w9 H/*****************************************************************************
5 p( }5 D3 S L7 e- W** Utilities+ g; z# F2 h: E2 ~
*****************************************************************************/! H* G( b) T3 R- l% o5 h
/* Unload Handler
' I) J" M: o. k0 N3 s5 q M** This function specifies when to unload your application from Unigraphics.
0 k/ T$ N; l9 w7 Y1 d** If your application registers a callback (from a MenuScript item or a' e% n* T; |$ r6 m0 A. P7 w3 c; k
** User Defined Object for example), this function MUST return! r0 t2 N9 X+ N3 I
** "UF_UNLOAD_UG_TERMINATE". */5 ^+ O" P) l0 v& O9 O
extern int ufusr_ask_unload( void )# K3 z/ I6 N6 y8 {7 R6 M4 p
{. T5 j5 z& l3 a" x; a/ v% ~
return( UF_UNLOAD_IMMEDIATELY );3 [. Y T" e0 q( _" o( S4 g
}/ Z7 a& j9 B( F4 i5 O, R: W
" X7 p. v4 B. O# j( n |
-
|