📄 message.c
字号:
/*load head file*/
#include<ProToolkit.h>#include<Pro2dEntdef.h>#include<ProANSI.h>#include<ProAnimate.h>#include<ProArray.h>#include<ProAsmcomp.h>#include<ProAsmcomppath.h>#include<ProAssembly.h>#include<ProAxis.h>#include<ProChamfer.h>#include<ProClCmd.h>#include<ProColor.h>#include<ProComm.h>#include<ProConst.h>#include<ProContour.h>#include<ProContourdata.h>#include<ProCore.h>#include<ProCsys.h>#include<ProCsysdata.h>#include<ProCurve.h>#include<ProCurvedata.h>#include<ProDatumdata.h>#include<ProDisplist.h>#include<ProDtmAxis.h>#include<ProDtmCrv.h>#include<ProDtmCrvSketch.h>#include<ProDtmCsys.h>#include<ProDtmPln.h>#include<ProEdge.h>#include<ProEdgedata.h>#include<ProElemId.h>#include<ProElement.h>#include<ProElempath.h>#include<ProExpldstate.h>#include<ProExtdata.h>#include<ProExtobj.h>#include<ProExtobjCB.h>#include<ProExtobjDisp.h>#include<ProExtobjRef.h>#include<ProExtobjSel.h>#include<ProExtrude.h>#include<ProFaminstance.h>#include<ProFamtable.h>#include<ProFeatForm.h>#include<ProFeatType.h>#include<ProFeature.h>#include<ProFixture.h>#include<ProFlatSrf.h>#include<ProForeignCurve.h>#include<ProGeomitem.h>#include<ProGeomitemdata.h>#include<ProGraphic.h>#include<ProGroup.h>#include<ProHardware.h>#include<ProImportfeat.h>#include<ProIntfData.h>#include<ProItemerr.h>#include<ProLayer.h>#include<ProLayerR19.h>#include<ProMaterial.h>#include<ProMdl.h>#include<ProMenu.h>#include<ProMenuBar.h>#include<ProMessage.h>#include<ProMfg.h>#include<ProMfgoper.h>#include<ProModFeat.h>#include<ProMode.h>#include<ProModelitem.h>#include<ProNcseq.h>#include<ProNcseqElem.h>#include<ProNote.h>#include<ProNotify.h>#include<ProObjects.h>#include<ProParameter.h>#include<ProParamval.h>#include<ProPart.h>#include<ProPattern.h>#include<ProPecktable.h>#include<ProPoint.h>#include<ProProcstep.h>#include<ProQuilt.h>#include<ProQuiltdata.h>#include<ProRelSet.h>#include<ProReplace.h>#include<ProRevolve.h>#include<ProRmdt.h>#include<ProRule.h>#include<ProSecConstr.h>#include<ProSecdim.h>#include<ProSecdimType.h>#include<ProSecerror.h>#include<ProSection.h>#include<ProSelection.h>#include<ProSheetmetal.h>#include<ProSimprep.h>#include<ProSimprepdata.h>#include<ProSizeConst.h>#include<ProSolid.h>#include<ProStdSection.h>#include<ProSurface.h>#include<ProSurfacedata.h>#include<ProSweep.h>#include<ProTool.h>#include<ProToolElem.h>#include<ProToolinput.h>
#include<ProUI.h>#include<ProUICmd.h>#include<ProUtil.h>#include<ProValue.h>#include<ProVerstamp.h>#include<ProView.h>#include<ProWcell.h>#include<ProWchar.h>#include<ProWindows.h>#include<ProWorkspace.h>#include<ProWstring.h>
#include<UtilString.h>
#include<TestError.h>#define MAX_IN_LEN PRO_NAME_SIZE
ProError UserMessageDemo();
/*--------------------------------------------------------------------*\Application global data\*--------------------------------------------------------------------*/static wchar_t MSGFIL[] = {'u','s','e','r','m','s','g','.','t','x','t','\0'};static uiCmdAccessState TestAccessDefault(uiCmdAccessMode access_mode){ return (ACCESS_AVAILABLE);}/*===========================================================================*\ Function : main Purpose : Test the ProToolkitMain() function. main is optional function.\*===========================================================================*/main(argc, argv)int argc;char **argv;{ ProToolkitMain(argc, argv); return(0);}/*====================================================================*\FUNCTION : user_initialize()PURPOSE : Pro/DEVELOP standard initialize - define menu button\*====================================================================*/int user_initialize( int argc, char *argv[], wchar_t errbuf[80]){ /* Declare function */ int ProTestInstallationCheck(); int i, menu_id; ProError status; uiCmdCmdId cmd_id;/*---------------------------------------------------------------------*\ Add new button to the menu bar\*---------------------------------------------------------------------*/ status = ProCmdActionAdd("MyCmd",
(uiCmdCmdActFn)UserMessageDemo,
uiProe2ndImmediate, TestAccessDefault,
PRO_B_TRUE, PRO_B_TRUE, &cmd_id);
status = ProMenubarmenuPushbuttonAdd(
"File", "MyCmd", "Message", "show message",
"File.psh_exit", PRO_B_TRUE, cmd_id, MSGFIL);
return (0);
}/*====================================================================*\FUNCTION : user_terminate()PURPOSE : To handle any termination actions\*====================================================================*/void user_terminate(){
}/*==================================================================*\
FUNCTION: UserMessageDemo()
PURPOSE: Display messages and read user input.
\*==================================================================*/
ProError UserMessageDemo()
{
int i1, i2;
const int default_int = 0;
double d;
int irange[2] = {0, 10};
ProName wstr, default_wstr;
ProCharName str;
ProLine msg_line;
ProCharLine line;
ProError err;
FILE *msg_test;
/*------------------------------------------------------------------*\
Read an integer without a default value. Message will display as a
prompt.
\*------------------------------------------------------------------*/
err = ProMessageDisplay (MSGFIL, "USER Enter any integer:");
err = ProMessageIntegerRead (NULL, &i1);
if (err != PRO_TK_NO_ERROR)
return (err);
/*------------------------------------------------------------------*\
Read an integer with a restricted range and a default value. Message
will display as a prompt.
\*------------------------------------------------------------------*/
err = ProMessageDisplay (MSGFIL,
"USER Enter any integer between %0d and %1d: |||%2d", &irange[0],
&irange[1], &default_int);
err = ProMessageIntegerRead (irange, &i2);
if (err != PRO_TK_NO_ERROR && err != PRO_TK_GENERAL_ERROR)
return (err);
/*------------------------------------------------------------------*\
If user entered the default value - warn the user. Message will
display as a warning.
\*------------------------------------------------------------------*/
if (err == PRO_TK_GENERAL_ERROR)
{
i2 = default_int; /* Using the default */
err = ProMessageDisplay (MSGFIL,
"USER Warning: using default value", &default_int);
}
/*------------------------------------------------------------------*\
Read a double without a default value. Message will display as a
prompt.
\*------------------------------------------------------------------*/
err = ProMessageDisplay (MSGFIL, "USER Enter any double:");
err = ProMessageDoubleRead (NULL, &d);
if (err != PRO_TK_NO_ERROR)
return (err);
/*------------------------------------------------------------------*\
Read a string with a default value. Message will display as a
prompt.
\*------------------------------------------------------------------*/
ProStringToWstring (default_wstr, "default string");
err = ProMessageDisplay (MSGFIL, "USER Enter any string: |||%0w",
default_wstr);
err = ProMessageStringRead (MAX_IN_LEN, wstr);
if (err != PRO_TK_NO_ERROR && err != PRO_TK_GENERAL_ERROR)
return (err);
if (err == PRO_TK_GENERAL_ERROR)
ProUtilWstrcpy (wstr, default_wstr); /* Using the default */
/*------------------------------------------------------------------*\
Write a message that states the values entered. Message will display
as info.
\*------------------------------------------------------------------*/
err = ProMessageDisplay (MSGFIL,
"USER Values entered were %0d, %1d, %2(5.3)f, %3w", &i1, &i2,
&d, wstr);
/*------------------------------------------------------------------*\
Write the values to a file.
\*------------------------------------------------------------------*/
msg_test = fopen ("msg_output.dat", "w");
if (msg_test != NULL)
{
err = ProMessageToBuffer (msg_line, MSGFIL,
"USER Values entered", wstr, &d, &i2, &i1);
ProWstringToString (line, msg_line);
fprintf (msg_test,
"ProMessageToBuffer output |%s|\n", line);
fclose (msg_test);
}
return (PRO_TK_NO_ERROR);
}
/*====================================================================*\
FUNCTION : ProTestInstallationCheck
PURPOSE : Open a internationalized modal dialog with the test result
\*====================================================================*/
ProError ProTestInstallationCheck()
{
int window_id;
ProError status;
ProBoolean is_successful = PRO_B_FALSE;
/* Call a sample Pro/TOOLKIT feature */
status = ProWindowCurrentGet ( &window_id );
TEST_CALL_REPORT( "ProWindowCurrentGet", "ProTestInstallationCheck",
status, status != PRO_TK_NO_ERROR);
if ( status == PRO_TK_NO_ERROR )
{
/* Set flag for a SUCCESS dialog */
is_successful = PRO_B_TRUE;
}
else
{
/* Set flag for a FAILURE dialog */
is_successful = PRO_B_FALSE;
}
/*---------------------------------------------------------------------*\
Create and Display the dialog
\*---------------------------------------------------------------------*/
status = ProTestDialogCreate ( is_successful );
TEST_CALL_REPORT( "ProTestDialogCreate", "ProTestInstallationCheck",
status, status != PRO_TK_NO_ERROR);
return (status);
}
/*====================================================================*\
FUNCTION : ProTestStdCloseAction
PURPOSE : Close Action for Dialog
\*====================================================================*/
static ProError ProTestStdCloseAction (char* dialog, char* component, ProAppData data)
{
ProError status;
status = ProUIDialogExit (dialog, PRO_TK_NO_ERROR);
TEST_CALL_REPORT( "ProUIDialogExit", "ProTestStdCloseAction",
status, status != PRO_TK_NO_ERROR);
return status;
}
/*====================================================================*\
FUNCTION : ProTestInstallationURLCheck
PURPOSE : Open the URL for PTC Supports Web Page in Embedded Browser
\*====================================================================*/
ProError ProTestInstallationURLCheck()
{
int window_id;
ProError status;
ProComment url;
/*---------------------------------------------------------------------*\
Call a sample Pro/TOOLKIT feature
\*---------------------------------------------------------------------*/
status = ProWindowCurrentGet ( &window_id );
TEST_CALL_REPORT( "ProWindowCurrentGet", "ProTestInstallationURLCheck",
status, status != PRO_TK_NO_ERROR);
if ( status == PRO_TK_NO_ERROR )
{
/*---------------------------------------------------------------------*\
Load a sample URL
\*---------------------------------------------------------------------*/
ProStringToWstring ( url, "http://www.ptc.com/partners/hardware/support.htm");
status = ProWindowURLShow ( window_id, url );
TEST_CALL_REPORT( "ProWindowURLShow", "ProTestInstallationURLCheck",
status, status != PRO_TK_NO_ERROR);
}
return (status);
}
/*====================================================================*\
FUNCTION : ProTestDialogCreate
PURPOSE : Common utility for creation of dialog
\*====================================================================*/
ProError ProTestDialogCreate ( ProBoolean is_successful )
{
ProMdl model;
int dialog_status;
ProError status;
ProComment message_wchar;
ProComment title_wchar;
char * dialog = "pt_install_dialog";
status = ProUIDialogCreate( dialog, dialog );
TEST_CALL_REPORT( "ProUIDialogCreate", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
status = ProUIDialogCloseActionSet( dialog,
(ProUIAction)ProTestStdCloseAction, NULL );
TEST_CALL_REPORT( "ProUIDialogCloseActionSet", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
status = ProUIPushbuttonActivateActionSet( dialog, "CloseBtn",
(ProUIAction)ProTestStdCloseAction, NULL );
TEST_CALL_REPORT( "ProUIPushbuttonActivateActionSet", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
if ( is_successful == PRO_B_TRUE )
{
status = ProMessageToBuffer ( message_wchar, MSGFIL, "USER Succeeded" );
TEST_CALL_REPORT( "ProMessageToBuffer", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
}
else
{
status = ProMessageToBuffer ( message_wchar, MSGFIL, "USER Failed" );
TEST_CALL_REPORT( "ProMessageToBuffer", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
}
status = ProUILabelTextSet( dialog, "Message", message_wchar );
TEST_CALL_REPORT( "ProUILabelTextSet", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
status = ProUIDialogActivate( dialog, &dialog_status );
TEST_CALL_REPORT( "ProUIDialogActivate", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
status = ProUIDialogDestroy( dialog );
TEST_CALL_REPORT( "ProUIDialogDestroy", "ProTestDialogCreate",
status, status != PRO_TK_NO_ERROR);
return (status);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -