|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
: D: U3 W$ }* L `" H0 o5 C! l/*****************************************************************************, L! t) e" s6 S& H1 h0 K W5 E4 G- n
** ^+ G, m# d! Z$ f2 x: b
** createfilebox.cpp
|: }- v3 x6 Z9 M: o0 T( X**
; E- y' G0 z) U2 j** Description:
) |" K# G$ t# F5 t** Contains Unigraphics entry points for the application.. |3 ?% N( {3 d
**
g; j& N0 c, z*****************************************************************************/2 a5 l- a5 M( G4 C
/* Include files */
2 e: a, v0 J+ Q1 @# a#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )) q9 F" e) [; C
# include <strstream>! s, T! ~( v: ?' a9 y
# include <iostream>
* S/ I( ?6 Z! h1 F2 p% v [ using std:strstream;6 M$ Q3 B! {) y! ^1 z* O
using std::endl;
/ D$ m6 e' f+ [6 H( } using std::ends;7 Q" F6 P+ _- f3 ]! T f8 _
using std::cerr;
, C2 Y' L* S0 P' b3 I( {4 l. I#else
% ~) k* b1 G* B$ V9 ?4 r0 ~7 p# include <strstream.h># \- D# |* Y/ G4 ]
# include <iostream.h>
! r1 m. Q7 m& ?: _: R+ X7 {2 D" w( ^7 C#endif% C* p" c" r; o
#include <uf.h>" J7 ]3 E$ K' I! U2 ]& h- D+ U
#include <uf_ui.h>
- ` b6 P# V3 c#include <uf_exit.h>8 A* t0 ?" x9 e' T( w/ G9 [+ R) k
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
5 i6 x+ w% z% H4 Fstatic int report_error( char *file, int line, char *call, int irc)
7 _5 j; ?0 K0 ]( _1 A{# Q2 a- _/ L2 `9 [
if (irc)
6 V* N, o* L- q! b3 k0 A p2 i4 ~ {
. N# v3 k% X+ y% [1 T char err[133],7 x9 j D: V6 U3 M
msg[133];
. l6 S$ n3 w+ c1 C2 W# D0 F! f* b! \ sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
1 ~' f% f; v J irc, line, file);
6 b% S3 i% @& T/ n UF_get_fail_message(irc, err);
; n! C% ^ o4 [: I* G4 R- D9 Y$ @1 |" U UF_print_syslog(msg, FALSE);8 r4 p7 d5 W% ~1 h! \0 E2 H7 t9 H
UF_print_syslog(err, FALSE);- J b( \2 W, e
UF_print_syslog("\n", FALSE);5 `3 [' i- y4 \: d" \; A
UF_print_syslog(call, FALSE);
% ^9 h+ p8 D' S! U UF_print_syslog(";\n", FALSE);
/ a# O9 w/ Q2 C if (!UF_UI_open_listing_window())
( d( b7 t9 b/ h8 V8 |) | {
, Y+ {8 Y" p# Z r" i6 N" r UF_UI_write_listing_window(msg);: B, H" W0 ?" G; }! y
UF_UI_write_listing_window(err);
\1 i9 l( Q: t& _5 V3 ? UF_UI_write_listing_window("\n");! r% x/ a* o" ?( D! u# q7 ?) A
UF_UI_write_listing_window(call);# k) i1 g) b" I8 m3 e
UF_UI_write_listing_window(";\n");( J. E# h3 d% l* Q) J+ y
}0 [# I5 V, s4 z2 \
}
6 r( V% ]/ o/ c6 `# N+ C1 ?+ Y return(irc);
+ n& S2 I, P0 S) m) E}; r4 g9 E+ M5 T# Q3 w
# [0 Y: p! a9 K1 ]/*****************************************************************************/ v4 v' h1 m$ u* e) K+ |/ n3 z
** Activation Methods6 w' f4 Q2 Q n) @& _, L
*****************************************************************************/
7 q/ D7 ^: P# `4 X- y) `9 o/* Explicit Activation! ~' s! a. e! T- r
** This entry point is used to activate the application explicitly, as in
/ x, I6 W3 K! E" I3 [! ^0 m* @/ T** "File->Execute UG/Open->User Function..." */" N" |5 t8 z/ z0 y$ }" S9 \! X/ f4 m. |
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
: c7 E$ C+ O. p' Y{6 M& z+ h% R" w0 p q+ @
/* Initialize the API environment */! ^9 M7 q, O! k- i" G- d
char prompt_string[]="open file";9 P0 M0 ^* H+ X8 y
char title_string[] = "select file";, Z% O0 D' F* E, n3 V
char filter_string[] = "*.prt";. i3 n# f3 S5 ?; {" H: A, z5 n
char default_name[] = "my file";
$ r$ {- [7 q# ~4 Y/ U char filename[256];
" o" v- p" ~% l( _- {- i) } int response;
! p/ n1 |( N/ P& T5 ?5 M if( UF_CALL(UF_initialize()) ) 5 K% `' W7 `$ H% h$ d* M, d
{
8 j" a) x/ M [* E9 d: |0 j /* Failed to initialize */
( t0 z8 y0 K" a3 O+ s5 Q y, v, { return;
3 b% l4 v& G1 ? L2 E# n; O# i; e }& A: `3 i% H* S" L- ^$ h" n" Q
( O$ q4 Y, |( u9 r1 s6 r
/* TODO: Add your application code here */ M6 u! q( r/ j' @( g
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
. L( j; o; C! y6 r, d+ W; v5 a: s /* Terminate the API environment */
/ K6 T* `( P+ e* A( _; f UF_CALL(UF_terminate());+ W- Z5 ?9 `+ p/ l; G( n0 A
}
; V9 t8 O% s% B/*****************************************************************************
! V" w! @2 N. J, {** Utilities
3 _) h6 u" T8 ]% c, E*****************************************************************************/* R0 B! z/ r% h) u
/* Unload Handler8 ]8 Q( }; o$ u; \
** This function specifies when to unload your application from Unigraphics.
7 I: `& F' j3 q1 r** If your application registers a callback (from a MenuScript item or a9 ?; w; F$ I# ?5 L" K9 S* e( J
** User Defined Object for example), this function MUST return) \+ `3 J Q( [( Y' B7 h* x2 O
** "UF_UNLOAD_UG_TERMINATE". */
9 Y$ |5 ]' c( G8 {/ y6 _+ pextern int ufusr_ask_unload( void )
' n( ~) C( @2 N* m1 u5 F, z{) I$ E+ ~: \, @( r
return( UF_UNLOAD_IMMEDIATELY );
' W$ |! Y- v) j- N1 e6 `}
, m8 o( i8 r& h* h
0 E. j6 h2 U$ f" `$ c |
-
|