|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
1 ^( F* s9 @% _0 z; z
/*****************************************************************************: R9 R3 p. x' y8 n9 Z) w
**
9 q4 D k, t1 O9 Y** createfilebox.cpp
! _; n0 `, z7 ~7 S) g3 j**& z1 X4 }: N, q9 m0 ?
** Description:
0 h* c$ R( N8 ~$ Z4 b R$ L& j, j** Contains Unigraphics entry points for the application.
$ ?' K# Q$ r7 F: Y+ q! C( X) ?**; A' l3 ?3 R- U \( c8 p# `
*****************************************************************************/4 }- |7 g: n5 `5 t$ S, a1 v
/* Include files */
* B, l9 l/ G7 m* b6 T& `#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
6 Z0 e+ f. S& y$ t$ m& Z( v# include <strstream># t6 C* M, F2 A, c$ a3 X+ k
# include <iostream> k$ p' G, m& U: @& o
using std: strstream;' q: J. H& H2 R7 A+ p5 \/ |) u
using std::endl;
( c, x \* S, y7 \" ^$ m0 A7 f using std::ends;
& U; j+ W( x9 D$ q( i4 q8 }4 L using std::cerr;" B- [4 w+ ?9 M6 D2 E* }
#else- @, x0 p- w6 V
# include <strstream.h>
5 ]# r) [/ u) U D' h# include <iostream.h>
/ ^" o6 Q+ k: c/ Q9 c& u2 p#endif2 \ a. H! J8 s9 ]
#include <uf.h>: v, s9 j8 V' I. T9 ^! C: W6 O
#include <uf_ui.h>
; S0 s9 v( [ N0 C8 \- b#include <uf_exit.h>- V: Y, I% q3 X4 v6 Y' L; T/ z8 ~
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
; q, p6 ^" V7 i% F% [5 s* X7 cstatic int report_error( char *file, int line, char *call, int irc)
7 m0 [2 w( |' p8 q{
0 \& W- S+ @& [1 g. z$ { if (irc)
3 L4 o# y' S( Z6 N1 g7 m {/ h/ V; H, c' O* `% t: |
char err[133],
, f+ Z# g: O+ a$ ^ msg[133];4 D7 D1 l: l* Q/ [/ ?6 T
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",0 Q4 g6 p, G& q) U* v+ f
irc, line, file);
2 Q) s" C3 f0 f& j- G UF_get_fail_message(irc, err);0 c$ n2 n6 x- p$ Y# j
UF_print_syslog(msg, FALSE);1 Z# R, l5 K' b6 g9 \
UF_print_syslog(err, FALSE);6 x+ q) r' p* a
UF_print_syslog("\n", FALSE);
) U" g# C( P3 m: `2 C UF_print_syslog(call, FALSE);6 F: \/ k( U q0 `
UF_print_syslog(";\n", FALSE);3 p- L; I8 z* k0 M
if (!UF_UI_open_listing_window()), x! n: @# g/ b* C, r5 R0 j
{: ]5 c$ H; ~. c/ ]5 @) v }
UF_UI_write_listing_window(msg);. @ L( z- S' [( |
UF_UI_write_listing_window(err);
0 }: a/ y* @9 n: [ UF_UI_write_listing_window("\n");
$ t5 p* G5 d/ w4 c" } UF_UI_write_listing_window(call);: D8 ]( v1 Q6 J, z7 e) h, x2 i7 n
UF_UI_write_listing_window(";\n");! D% N" f- p: C5 R" M
}
8 O; k0 Q$ r: J v0 O; ? }2 c8 ?/ \7 c2 x: M1 M5 Z' H5 z3 i
return(irc);
8 w; x( @- W$ }! F. Q( X" p2 E9 U}
m1 V$ d8 @9 ]6 h+ e
! s. J6 g, t4 P# i2 `9 t5 y' I/*****************************************************************************
6 ?9 e0 R/ H: f( E8 d; e4 T' r$ g** Activation Methods
, [; I5 ~, f. q& u*****************************************************************************/8 b& I! n- _6 g: ]4 K
/* Explicit Activation) |8 v& S2 n# B9 a3 U! a0 d
** This entry point is used to activate the application explicitly, as in) d. v$ ^# _ K. y1 Z$ E* U5 G* Y
** "File->Execute UG/Open->User Function..." */
G6 t1 \" }. C8 F: ? I1 U" w$ Mextern DllExport void ufusr( char *parm, int *returnCode, int rlen )! Z+ c& E- J8 Y5 z7 ^
{( z7 K1 d- F5 D: Q: c
/* Initialize the API environment */
& S- |6 C8 k5 a9 [ ?/ x8 f* v0 t char prompt_string[]="open file";8 M1 a8 o" Z7 T D* z1 N
char title_string[] = "select file";- F7 j0 d8 a. D c1 r' [
char filter_string[] = "*.prt";
* u2 S1 F- }' {4 D6 {$ R/ y/ u char default_name[] = "my file";% q# k7 A1 S1 m4 A1 m4 P
char filename[256];
, D0 r- j. Z: e: p$ D) p4 Y int response;; D3 y" C+ U0 e* V, { z
if( UF_CALL(UF_initialize()) )
! M( P F4 ~4 j' P0 ?9 g {1 P, ^$ A, X+ \- b- n" B: ]% ?' h
/* Failed to initialize */
% ]4 ]5 Q9 ?$ u' N1 ? return;
$ @: c2 y7 w4 |0 T$ M: L }
# Z7 a8 e% H( g2 t5 J( O5 r* F, _
7 `$ g1 A0 I* c1 \0 f /* TODO: Add your application code here */! R+ u) h2 K# A' {- N8 L8 G6 o
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
2 I. ?6 d3 [0 Z5 l" R, u /* Terminate the API environment */6 r- X: o! i; M0 _5 T. b. b
UF_CALL(UF_terminate());' f0 |$ v5 w! f: N0 D: \
}' w2 z( d% `# J9 F: J2 n" V
/*****************************************************************************
+ d5 C+ I/ Y7 ~% c, [6 Y0 Z' t** Utilities9 E- [ Q% W* ]# D ]; \) ^
*****************************************************************************/
, \0 {6 d& H! | c! Q4 u& G/* Unload Handler L' L: o6 ?( c3 _
** This function specifies when to unload your application from Unigraphics.1 n) N7 m6 I8 c4 E; f5 a9 N U
** If your application registers a callback (from a MenuScript item or a E9 i$ p; i2 ~- u+ T6 b& B
** User Defined Object for example), this function MUST return% x) a5 b: r3 s, u1 S2 [
** "UF_UNLOAD_UG_TERMINATE". */+ z9 W5 ^ u( j* V' r
extern int ufusr_ask_unload( void ), x. p2 l1 ]) y0 M6 l
{; d- j' ~' w9 l( m7 a6 x9 M
return( UF_UNLOAD_IMMEDIATELY );
. s- h$ u2 F1 J}
$ R0 P+ v7 R ]# W" W& c) }4 u) `8 D3 z. [( b; R# |! r0 n
|
-
|