|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 M" i, }6 _: Z1 U$ h" b/*****************************************************************************
, p% t$ m) w* ^/ E$ L**% P4 J+ P( A3 C6 X" _$ l) v
** createfilebox.cpp
Y; Z7 M# |2 V! L! v**
. i1 n6 W8 X4 H; D! _** Description:* W: s, U8 l1 V8 g9 `/ a: [5 x
** Contains Unigraphics entry points for the application.
# V$ o1 ` M8 _. G& T Y**/ T/ m+ X, V2 l" R! w
*****************************************************************************/$ i3 w3 Z/ k, }+ Z7 o+ S3 q
/* Include files */
) ^9 N5 K: h9 J/ G( S9 R k#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )+ n* j7 _( m* F9 T- d
# include <strstream>. o5 U3 i" [0 G7 E4 V2 F
# include <iostream>* z8 S+ a- I5 b! N' S
using std: strstream;
" v# s7 k3 L8 v1 b& G& | using std::endl; $ n" A* N1 g9 {
using std::ends;
; E/ {) u( n F' L4 Q using std::cerr;
. ]/ y$ n6 M8 Z! C#else
( `! M* L f+ G+ R8 ?8 s$ `& _9 u# include <strstream.h>
( t2 ~9 Q+ H( Q# include <iostream.h>
; A( P: C% _0 `1 E1 v- S#endif- [' f4 n% q: p- z$ |3 h0 P
#include <uf.h>
0 _& d8 U# _$ a" {9 q#include <uf_ui.h>
- A W* c/ V# D2 a( | i#include <uf_exit.h>/ |! A8 f( L9 Z+ r! n( a
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
) [+ ~6 g. s: [7 a/ hstatic int report_error( char *file, int line, char *call, int irc)
4 u2 K* a+ j* d9 V: k) B! G{
% Z$ ^4 c* d, M1 Z7 r* Q/ { if (irc)7 x; `! E7 I3 X. q% x5 u: a n
{
" i1 [. R. X( I& F char err[133],/ p. u- c3 Q; {% m8 H0 J) w
msg[133];" _ p) @+ G; J
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
7 L8 \) K' l. J' I( G5 X4 o( y irc, line, file);# f- m8 V7 w7 E$ Y
UF_get_fail_message(irc, err); ~7 s, f9 W! U0 f
UF_print_syslog(msg, FALSE);
' E2 n" c4 z, B UF_print_syslog(err, FALSE);% W8 ^6 ^( p! B
UF_print_syslog("\n", FALSE);0 B. [' V* O) B Q8 r0 b! A% [
UF_print_syslog(call, FALSE);
5 o/ }0 T9 U; ~; ~5 `! g UF_print_syslog(";\n", FALSE);: [. ~* u/ ~9 ~% C1 N K$ k
if (!UF_UI_open_listing_window())
8 ^! x& e4 C- Y, O$ ^- R6 y {
3 P: r! S4 }# {& D6 ^5 }; I3 [, Z UF_UI_write_listing_window(msg);
& w! N$ m; `. Q Z9 j UF_UI_write_listing_window(err);1 ]3 e( _9 s# V
UF_UI_write_listing_window("\n");! L' a5 L) Y1 M8 Y' ^& t, W
UF_UI_write_listing_window(call);5 ?3 w7 i- w+ W
UF_UI_write_listing_window(";\n");9 S$ w7 o0 N9 H" c+ s
}
1 {' D0 b0 q7 |4 N! D5 `4 k }
o6 J& u) L! [0 c4 d V return(irc);& U( i# n: G9 q S+ K
}2 b( F% ]4 L3 i- M: z8 H
' C& l n$ Z. }* ^) h3 Y/*****************************************************************************
2 s+ b5 F: W$ Q/ }% I0 ^** Activation Methods* \/ J& i [2 z4 I2 m3 z
*****************************************************************************/
( ?5 N; ~" x0 s* j/* Explicit Activation
/ G; I4 n/ s# h) ~5 t! z** This entry point is used to activate the application explicitly, as in$ R0 i% S6 I7 @+ a
** "File->Execute UG/Open->User Function..." */
8 e2 Q4 A! H3 J+ ^8 R. aextern DllExport void ufusr( char *parm, int *returnCode, int rlen )3 m: p h0 F# [. U0 ?
{
! F- U/ W0 _3 R /* Initialize the API environment */: H$ ^- d% s; b& i2 K
char prompt_string[]="open file";
" {% Q+ ^6 o' _, X6 E char title_string[] = "select file";# A% t' t2 i2 j8 w. t
char filter_string[] = "*.prt";* y. M/ K$ O/ e4 ~/ J/ ]4 U
char default_name[] = "my file";
0 ~9 X2 r c& O+ h0 n char filename[256];9 P" k5 i1 g+ P& K! Q
int response;
" V6 A6 k2 I+ d; t( D if( UF_CALL(UF_initialize()) )
C' ?& N" c. \/ x: \ {9 S3 t# k& h4 T/ f8 S+ [# p
/* Failed to initialize */
6 @" [7 D$ R/ R7 z9 Y3 O return;9 v8 A! I; @. w3 P9 |
}
2 X' f! `( ~9 Q$ n: F
4 p% P: a! \: k /* TODO: Add your application code here */
: U/ k1 a8 V, H3 P! \" C UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox; a- I! ?/ p; K+ N
/* Terminate the API environment */
/ D' l) @. z- @2 E0 U UF_CALL(UF_terminate());& n" T$ A& v& B( t* d. S
}( |8 j6 g9 }; r) I, g- K+ |6 R
/*****************************************************************************
$ D% }4 x( s- u** Utilities* E: ^ u1 ^7 Y7 ?' Y
*****************************************************************************/' K; g2 i' M- j1 d& @
/* Unload Handler! X$ z- w' n0 q/ W. P
** This function specifies when to unload your application from Unigraphics.
1 C' |3 O& t0 R** If your application registers a callback (from a MenuScript item or a: T* {" V- ], B7 P" h+ ^ L
** User Defined Object for example), this function MUST return
' t v% B2 U$ J3 o3 B5 E# O' D9 e3 F9 c& |: b** "UF_UNLOAD_UG_TERMINATE". */ n. s* C, T& H& _ G' l
extern int ufusr_ask_unload( void )* m/ I! y. M* f: M- ?- n6 h
{
2 a' _0 N3 \2 J f3 } return( UF_UNLOAD_IMMEDIATELY );
M1 X: a0 p; X) m}
C5 L4 g9 H# F5 K/ K" g# U8 k6 m% K4 j& |3 f5 s
|
-
|