|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 z0 L( ^: a& R2 Z
/*****************************************************************************: G" G: f( j- b
**
1 l% g# v( ~" j7 _- I** createfilebox.cpp
, ^1 `8 E$ u) [8 p: I**
4 W% T- {" Y% u! ?6 f. t** Description:
6 d( J& D* U2 Z. r6 [, l' r** Contains Unigraphics entry points for the application.
9 W2 |& M0 o8 C* K( u8 i**! t& P" O7 }' p& B! `
*****************************************************************************/6 n/ D5 P3 Z" \+ N \4 i0 a- t. `) v
/* Include files */
1 ?; w3 T8 ]" J! a( ]#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )/ t/ L/ H$ {7 h
# include <strstream>, P, S' l4 l5 S4 h
# include <iostream>1 H, |+ `1 b {- ^/ [# P
using std: strstream;
$ Y$ i; J% N+ W2 K! j" D& b using std::endl; ! C2 C" }8 t7 x4 T8 V
using std::ends;
% U d0 I/ C: x! h. r) y using std::cerr; a& p# o# K% n1 @& |" E/ Z
#else
! s; y5 x0 O) m# P. R# include <strstream.h>
7 f1 C) I; \: a* N8 b( {! ^, T/ \# include <iostream.h>
) e+ N/ j4 m/ r1 G) A- K#endif
3 u* Y4 S/ S% Y2 x& x% @#include <uf.h>
! v) | b- w+ `" ~, u#include <uf_ui.h>
3 p& R/ K0 e' s& t- F#include <uf_exit.h>
, }4 [' D) h3 J#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
9 T6 F$ O5 Q5 X5 I$ w) j0 cstatic int report_error( char *file, int line, char *call, int irc). {4 I4 E) Y0 p/ P- T& a C( c3 ?' O
{
2 O1 a+ y `+ c7 S0 E0 f if (irc). ~6 R4 z# [& o2 f1 V
{. K; _# b1 n! n& u) W
char err[133],' O9 m2 J* \; f6 g1 {4 Y! _
msg[133];7 \) Z& G9 T6 V! T! @" e1 ]/ c, r0 G
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",: N9 P" a% x' Q% U! G" q- R3 _! d% ^5 V
irc, line, file);
6 P0 s3 j: `8 q( }3 | UF_get_fail_message(irc, err);! o% R4 |- I9 ^, D6 r3 X9 O* }
UF_print_syslog(msg, FALSE);
4 m6 l1 v8 J; \7 j5 u+ Z UF_print_syslog(err, FALSE);
: ^3 t: d! F0 q8 E3 X) d* a% ?( } UF_print_syslog("\n", FALSE);6 w5 k# V# L8 x6 l
UF_print_syslog(call, FALSE); t& R# I- z8 U! A g5 ]
UF_print_syslog(";\n", FALSE);$ N4 ~7 O4 D: s
if (!UF_UI_open_listing_window())' i( A4 s) m! I
{6 C4 k; J# ]3 g) j; c C
UF_UI_write_listing_window(msg);3 X! U; W) p' M' Q+ O% F* h5 m
UF_UI_write_listing_window(err);, g) T3 @' m7 ~
UF_UI_write_listing_window("\n"); _: _8 k( i: \8 H
UF_UI_write_listing_window(call);8 {6 r V- F9 q; E: r( B. c
UF_UI_write_listing_window(";\n");
# {) a' h7 q" e8 l' X }
2 e/ Q) q! y; @ }
: ~- c0 p) }: u% c8 M' U$ `. S& i return(irc);
' u' o8 j: P4 }/ Q}
v. Y3 T5 f) ~& S/ U# o* Y8 h
: w! }8 \! C) e8 u) P2 d/*****************************************************************************
5 L$ c- Q( R; |- |6 y$ Y** Activation Methods: b( F# ?. x" x. `0 G i$ L$ d
*****************************************************************************/# g5 ^* W# d+ j' Q, O" ~' r9 Q: B
/* Explicit Activation
2 I+ y1 X& v2 Y* b* C** This entry point is used to activate the application explicitly, as in
& Z6 _4 P- M; R** "File->Execute UG/Open->User Function..." */
; J+ _: K; q# q" z5 n! c2 Fextern DllExport void ufusr( char *parm, int *returnCode, int rlen )8 d/ s) S* ^3 Y% \* k
{, Z' Y$ C4 `! j: w5 i F
/* Initialize the API environment */4 l) A5 s6 C7 @! T8 f' r) ?2 K
char prompt_string[]="open file";
" w$ }" U( Z) v6 Q9 a( H char title_string[] = "select file";
2 V; |5 b2 f0 a4 r5 i( E6 t char filter_string[] = "*.prt";) R! h2 i% c# C# |
char default_name[] = "my file";
8 z. z7 {9 E8 d \ char filename[256];
4 H. U8 ?; z& @; K8 W% `- C& x int response;2 r) C ]% h5 n& ^9 ]( _! d, V2 o
if( UF_CALL(UF_initialize()) ) 6 n. C+ e$ \' G' P
{! T9 Y( h! B' m5 r7 R
/* Failed to initialize */+ d k5 ?$ Y: K& M" j
return;
' Z8 g$ g" Q9 g }
9 [) w- e. ?5 p! H3 r + o+ v6 j( |8 q
/* TODO: Add your application code here */
8 p" k7 e% w% P9 n UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
: k& ^4 n" h; Z8 [6 q3 C( d; ` /* Terminate the API environment */% l& y5 ?' a4 J+ j2 K3 Z
UF_CALL(UF_terminate());
6 x5 m9 j# L% G2 \}
' w9 Y% Z' l/ y& o. u" _, c3 j3 d5 _/*****************************************************************************/ H; _' M) O# d. l/ R8 W9 h
** Utilities
+ V3 x& j9 `! w$ {*****************************************************************************/
! T; D. Q% W! @, _ |! J/* Unload Handler6 P- [: B0 `. r8 b2 p" ?
** This function specifies when to unload your application from Unigraphics.3 y! u; D0 m. J0 v: k. O
** If your application registers a callback (from a MenuScript item or a
5 Y1 s7 I+ f1 n- ~& ?** User Defined Object for example), this function MUST return
. _( H3 @% p* {* W7 b** "UF_UNLOAD_UG_TERMINATE". */! W! T6 y5 d" ~# n) e, X s1 d; V* V
extern int ufusr_ask_unload( void )6 ]! \+ J- u; m$ A- R
{# c6 G, E" `2 u( Y, G, a
return( UF_UNLOAD_IMMEDIATELY );' L2 X, j& n$ [- ~/ y4 u
}: K& D( Z0 g: \- R7 v5 ~
) ~/ E2 o# f" H) H6 C0 \ |
-
|