|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 S; `2 n4 k. h
/*****************************************************************************% N; d# ?. t( y+ z2 a9 M h/ ~" [' @
**
$ J; V I( |: F6 S. K) j** createfilebox.cpp7 |: B3 X j, r9 u, v7 j9 M: n
**! C! W% G1 w1 A' ?5 t% O" ]* O
** Description:
$ i1 i( Q* g: c4 c) n& |; r** Contains Unigraphics entry points for the application.
! U* w! _4 f$ Q: k: T, E" K**
& e1 {1 Q7 y5 U) c*****************************************************************************/
' U! W$ W. q. N0 b4 D/* Include files */
/ F. @; i- Z T- }. j#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun ). Y" g! d8 H& V
# include <strstream>4 U4 f5 I6 e9 N( L
# include <iostream>
5 U& `- ?# ~0 ^" N; h9 R using std: strstream;* u Q8 Y; Z s3 J
using std::endl;
* }) ~; h- B2 }+ [ using std::ends;! v$ v1 f9 f( }" y1 p: T; u
using std::cerr;% z' Y c: H9 P1 F6 e) I
#else4 f# R% s6 D; I( q$ d
# include <strstream.h>
# H7 h5 u( O6 E/ A+ y- G# include <iostream.h>
6 p9 T" o o6 z+ N5 G- e" Z8 y" o#endif
2 |$ }' g' c/ ]& C9 l" A7 }#include <uf.h>
+ [# ?: }. ], ]8 M$ J$ O N5 b( U6 L& {#include <uf_ui.h>! E2 W* v- f H5 m; b" h0 l, `/ {" C5 V
#include <uf_exit.h>% w5 R; e/ M- [& h6 }( V! \
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))); @. p1 Y8 a" ~4 M9 z8 w4 X
static int report_error( char *file, int line, char *call, int irc); y$ e8 b- r: X ~* x, E
{( w$ R; z ~/ X" l$ F4 N, n0 V. I
if (irc)
8 D6 s+ I6 k6 H {5 n( \4 ]7 m0 ^. s
char err[133],) {, F& R0 @% N/ u" r7 e, {
msg[133];
J5 G+ k2 C/ P1 Z sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
3 J8 G1 l3 c0 F# x% ?# T; [6 ? irc, line, file);
Q4 ^7 D9 r0 f1 n" \" O& B$ ^2 y UF_get_fail_message(irc, err);
( G6 r m3 D! V; K UF_print_syslog(msg, FALSE);$ H1 I" P9 a; i0 w) z
UF_print_syslog(err, FALSE);- s' w5 \" W, P: f* j. |
UF_print_syslog("\n", FALSE);) _! X k& ]! r1 O# ^" u, c
UF_print_syslog(call, FALSE);4 H* Z/ e/ g& x- A& ?; y0 z
UF_print_syslog(";\n", FALSE);
- i# r( A( m7 H if (!UF_UI_open_listing_window())9 ?; Y" i: f0 M! F1 F: O
{
1 e! Q4 D9 P: M: C& M! \/ `" N UF_UI_write_listing_window(msg);
0 o) h+ a! U H6 }* h& q- j UF_UI_write_listing_window(err);" k8 T) `0 m1 R' D3 j2 L
UF_UI_write_listing_window("\n");
6 C& k! L. U$ k% {4 @$ L UF_UI_write_listing_window(call);
8 ^! D* Y8 x) _0 z- L. | UF_UI_write_listing_window(";\n");/ U: d! `& s! V, R/ C
}8 M8 i A0 Q# n( t( I4 e
}' a3 W% \3 O+ j `) c6 M* d& O# ?
return(irc);2 H5 D& }* Y5 U
}. G: R. l1 W% W: d( R! {
/ D- J' v+ `7 V* b' s1 ?/*****************************************************************************
/ R' O) Z/ @6 Q. _/ f** Activation Methods
" _; t, y" E( U8 q*****************************************************************************/- Y+ S9 f( o F7 Y. P: k+ k( t
/* Explicit Activation2 f/ E& ~& }8 x# |5 M
** This entry point is used to activate the application explicitly, as in
6 S+ _4 o( J+ V: s" P$ h6 n) z** "File->Execute UG/Open->User Function..." */6 O) e! p: o# Q2 w& ^
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
, w$ C. j: j5 ]" d. O; J% c- |{
& f6 [ ?% B0 z" G /* Initialize the API environment */
- C! n0 ], p/ d; O$ r6 m# ^6 O char prompt_string[]="open file";
; q, u; R( [! z6 x2 Y. j char title_string[] = "select file";! Y7 B' H' y' z" Q; h( D d7 B( D
char filter_string[] = "*.prt";
1 n' C$ r6 d& A, n1 D: c) v' j char default_name[] = "my file";
: F( m: ]2 j. L8 z9 B char filename[256];4 A! a8 p' u$ f3 k* Y, ?
int response;
% |5 m+ n! q5 X# \/ }9 ? if( UF_CALL(UF_initialize()) ) 6 K3 d+ {4 s+ X1 `- K! p& K; a
{! I! K. \/ A5 X9 V$ K* y
/* Failed to initialize */
1 Z/ y$ O0 W4 A4 c6 G return;
' P# J! ^# R, `- n2 D }
9 X2 T* x. C3 V+ B7 b* d$ B( ^ " V! T8 O" n8 M8 o
/* TODO: Add your application code here */
5 f* I% |' E6 c* ^& e. d/ d UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox9 p3 V0 F3 n; ^1 a
/* Terminate the API environment */- r# d( k& h. B3 _
UF_CALL(UF_terminate());
! t: W, O$ u, A8 c7 d& T7 ~}
! q3 B5 L0 ]5 {! y9 a/*****************************************************************************
) h U; }5 y" d$ l** Utilities8 H5 q5 j, y% H' e Z4 }- \
*****************************************************************************/
e" N) S4 e; H/* Unload Handler# c- u7 z5 f# e4 {. K$ g
** This function specifies when to unload your application from Unigraphics.7 x+ ? n( A/ H" {
** If your application registers a callback (from a MenuScript item or a
: }. x \) Q1 w. ^) F/ z8 L** User Defined Object for example), this function MUST return
- Q* z; s. k- M$ K5 B** "UF_UNLOAD_UG_TERMINATE". */
) k, T+ z0 g p8 A; V$ Aextern int ufusr_ask_unload( void )+ @( z0 Y6 ~0 G4 u
{
% g U9 h' d2 F7 s' g return( UF_UNLOAD_IMMEDIATELY );. o% g! H3 }) R/ n7 h8 f R
}) |2 s% t! N1 ^: K
x% z2 Q: c0 e- k/ b |
-
|