|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
! _7 Z C! }- y' c# e
/*****************************************************************************9 x: q( ]" Q6 X7 ]: A/ W
**
! [( N* F/ a' o8 ?, k& e** createfilebox.cpp
, l# D) V+ E+ w" a! b0 d9 N9 V5 D**; {/ G4 _7 W# u1 X2 R8 ~
** Description:% e; C; o8 p: K m4 R r: O
** Contains Unigraphics entry points for the application.
! J4 X- S6 H) Q o$ b: B& x**5 t3 R/ g# d9 i
*****************************************************************************/
# D" B) Q; ^/ y8 x9 `, ?/* Include files */
" V' }. B$ y5 E2 ]/ x' B#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )2 C5 a: w+ v3 i
# include <strstream>
7 d) J- q) o; m& p! X1 N# include <iostream>
8 C1 B* [) Y( f+ K using std: strstream;/ w$ j+ G: E8 }) w; e. C" w
using std::endl;
5 X6 H% y- k3 w% h) O using std::ends;
2 s/ {% k' D& w. R# b using std::cerr;
8 i- W- s8 [9 q/ H9 Y#else
1 F6 F5 \- z. [$ I* C, V. D- C# include <strstream.h>
0 e; O) z8 v; C8 m" |# include <iostream.h>
+ Q( [, Q, F, g: | v9 W#endif
" ]! C) o+ S3 R#include <uf.h>
+ G J( L) r4 ?2 w#include <uf_ui.h>
& \: ?) e: I! x3 O* I8 i$ |' C0 G#include <uf_exit.h>% m1 Y, n% t1 A# N4 t& ?1 B# k
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))): W) l3 h1 F% ~8 O
static int report_error( char *file, int line, char *call, int irc)- r% Z7 f- _& X
{5 ~8 A( T" h5 z* s2 y9 m
if (irc)/ l1 L8 I& u5 R, \; \6 s) \
{& S q/ w8 k2 t% t6 c
char err[133],! f4 `( B. @! P8 Y
msg[133];* |# c& f( D, g: M2 a
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",1 g* d, t% U4 H% }$ f8 Z1 ?0 h" ?
irc, line, file);
( x% t G$ @2 Z; k0 \9 Y' p UF_get_fail_message(irc, err);
$ B; L/ J u/ t/ q: \8 } UF_print_syslog(msg, FALSE);* e2 _! @, b5 [$ D6 z+ `1 ?8 G. a# \
UF_print_syslog(err, FALSE);' s; b. ^% s4 b& x2 j! o
UF_print_syslog("\n", FALSE);5 q0 W/ U R! P4 G; C
UF_print_syslog(call, FALSE);
* `8 A% i! L t& b UF_print_syslog(";\n", FALSE);& k8 b2 V9 g4 P# a% k' _$ R6 W
if (!UF_UI_open_listing_window())* X3 q/ @4 y+ D3 p, N& M- h! l
{
5 b2 x/ a" `" V. E& V! f UF_UI_write_listing_window(msg); Z# Z# }& [# g
UF_UI_write_listing_window(err);" f7 U) \! `! \. K
UF_UI_write_listing_window("\n");
2 \+ D- R1 o# r$ D UF_UI_write_listing_window(call);
6 P# Y: s0 u9 \; N7 A& o8 o& e UF_UI_write_listing_window(";\n");9 X% w: t* T8 B+ g
}3 b$ O4 G9 g9 n# B1 r7 O$ B
}6 U* @2 h/ l# M
return(irc);
: B4 g' |* l1 H/ {( m2 V}
! \( T, b/ V1 F
) f% H0 c* L3 c/*****************************************************************************6 H1 t4 W ]9 l4 p, d
** Activation Methods
y# {( s' e, p) M6 g5 y7 V3 F5 |*****************************************************************************/6 I2 s6 A; j- K
/* Explicit Activation/ u( r4 _4 y. h
** This entry point is used to activate the application explicitly, as in
* U- t. k" K; }- a# {** "File->Execute UG/Open->User Function..." */2 |' R4 I3 F; D: ~
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )4 [5 M# N) N( I8 Z o B
{' c% U$ V3 i4 m" \2 k7 L7 [
/* Initialize the API environment */2 [7 E( M& T9 `* h: H
char prompt_string[]="open file";
; Y, q; h& {0 {7 T5 c8 W/ I char title_string[] = "select file";
' `- `& k! Z7 U9 t char filter_string[] = "*.prt";
- j% j1 a+ g6 h8 Y# H( d1 H( h0 N char default_name[] = "my file";+ _& N7 \/ \! X/ N, f6 |
char filename[256];
) ]8 N7 f# m) o; y int response;
7 k8 s2 y! U1 {! ]+ e if( UF_CALL(UF_initialize()) )
" n3 A4 b; b! J0 a _9 J* v. f {
5 ~$ O8 q) o" l6 D /* Failed to initialize */: c0 q. V% t( M* ~+ t1 e2 t, m# k9 ?
return;% q6 A) M( t5 }( |% \$ h
}- U6 N# M1 ]0 y
6 \$ a) N2 [. r, {
/* TODO: Add your application code here */& A- r3 K4 q6 I2 R& T" g2 [3 l
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
. E" {5 e# z" L) q /* Terminate the API environment */% v( X U# }" p; k' |9 S: ]! T
UF_CALL(UF_terminate());
# U3 ]7 j) N, O5 K2 W2 o}
; Q) m) O/ [/ |# J/*****************************************************************************
6 g) m$ r/ N, \$ k8 V; V8 R/ @** Utilities' l7 P$ v' ~: [6 z: l# m
*****************************************************************************/3 w5 g/ M- O# Q0 i
/* Unload Handler
6 G2 z" H) M, H" I** This function specifies when to unload your application from Unigraphics.
" l1 @ H9 H' x6 p9 L** If your application registers a callback (from a MenuScript item or a
/ t$ I1 L2 k, T2 G; M7 B6 Z7 z) N** User Defined Object for example), this function MUST return% f' A$ N, v+ ^! C) C" C
** "UF_UNLOAD_UG_TERMINATE". */
; n% v ~, X* L Nextern int ufusr_ask_unload( void )
/ Z; o7 G/ ~% S: P) X* c7 N& w{
) |$ z& T+ G6 a2 E, h8 t# F( q return( UF_UNLOAD_IMMEDIATELY );
2 v7 b% n- }5 ? ?}( T( X4 F9 u( T+ P1 \; @# y. E W
! i! R3 W$ X4 r( D) p/ |2 M
|
-
|