Hi!
I'm new in programming with Pro/Toolkit and I want to make a little program that can generate gear wheels and edit tables by reading parameters out of a loaded text file (quite similar to ProGearwheel...) I'm using Pro/E Wildfire 4.0.
Making the menus wasn't that problem, but now I got stuck at creating a dialog, though I've read the API (ProUIDialog and everything that goes with it), the helpfile (UserInterface...) and the examples over and over again.
The problem is that nothing happens when I click on button 1 in part mode (Create Gearing), except the Testing-Message is shown (which means that MiscAction1() works, doesn't it?). Button 2 (Create Table) works well (Testing-Message is shown) in drawing mode.
Due to reduce complexity I slimmed the dialog to a single OK button which closes the dialog
The dialog.res file should be correct and in the right directory (I need it in two languages).
The problem seems to be similar to this one:
http://www.mcadcentral.com/proe/forum/forum_posts.asp?TID=34 964&KW=dialog
But the only answer there didn't help me on.
Here is my code:
#include <ProToolkit.h>
#include <ProMenuBar.h>
#include <ProMessage.h>
//#include <ProUIDialog.h>&nb sp;
//#include <ProUIPushbutton.h>
#include <ProMdl.h>
#include <ProUI.h>
static ProFileName UserMsg;
static uiCmdCmdId cmd_id1, cmd_id2;
ProError MiscAction1(); //
ProError MiscAction2(); // do I need this here?
ProError CreateDialog(); //
/*========================================================== ===*\
FUNCTION: AccessGearing()
PURPOSE: Define the accessibility of "Create Gearing" menu button.
\*========================================================== ===*/
static uiCmdAccessState AccessGearing (uiCmdAccessMode access_mode)
{
ProMdl current;
ProMdlType type;
ProError status;
status = ProMdlCurrentGet (¤t);
if (status != PRO_TK_NO_ERROR)
return ACCESS_UNAVAILABLE;
status = ProMdlTypeGet (current, &type);
if (status != PRO_TK_NO_ERROR || type != PRO_MDL_PART)
return ACCESS_UNAVAILABLE;
return (ACCESS_AVAILABLE);
}
/*========================================================== ===*\
FUNCTION: AccessTable()
PURPOSE: Define the accessibility of "Create Table" menu button.
\*========================================================== ===*/
static uiCmdAccessState AccessTable (uiCmdAccessMode access_mode)
{
ProMdl current;
ProMdlType type;
ProError status;
status = ProMdlCurrentGet (¤t);
if (status != PRO_TK_NO_ERROR)
return ACCESS_UNAVAILABLE;
status = ProMdlTypeGet (current, &type);
if (status != PRO_TK_NO_ERROR || type != PRO_MDL_DRAWING)
return ACCESS_UNAVAILABLE;
return (ACCESS_AVAILABLE);
}
/*========================================================== ======*\
-------------------------CREATE GEARING-----------------------------
\*========================================================== ======*/
/*---------------------------------------------------------- ----------*\
FUNCTION : UserOKAction()
PURPOSE : Action function for the OK button
\*---------------------------------------------------------- ----------*/
ProError UserOKAction()
{
ProError status;
ProUIDialogExit("dialog", NULL);
return(status);
}
/*---------------------------------------------------------- ----------*\
FUNCTION : MiscAction1()
PURPOSE : Action after clicking on "Create Gearing"
\*---------------------------------------------------------- ----------*/
ProError MiscAction1()
{
ProError status;
status = CreateDialog();&nb sp;&nb sp;&nb sp; //nothing happens!
ProMessageDisplay (UserMsg, "USER Message1"); //is shown
return(status);
}
/*========================================================== ==========*\
FUNCTION : CreateDialog()
PURPOSE : Creates Dialog
\*========================================================== ==========*/
ProError CreateDialog ()
{
ProError status;
status = ProUIDialogCreate( "dialog", "dialog" );
status = ProUIDialogCloseActionSet( "dialog", (ProUIAction)UserOKAction, NULL );
status = ProUIPushbuttonActivateActionSet( "dialog", "OK", (ProUIAction)UserOKAction, NULL );
status = ProUIDialogActivate( "dialog", NULL );
//status = ProUIDialogAboveactivewindowSet( "dialog", PRO_B_TRUE); // Do I need this?
status = ProUIDialogDestroy( "dialog" );
return(status);
}
/*========================================================== ======*\
-------------------------CREATE TABLE------------------------------
\*========================================================== ======*/
/*========================================================== ======*\
FUNCTION: MiscAction2()
PURPOSE: Action after clicking on "Create Table"
\*========================================================== ======*/
int MiscAction2()
{
ProMessageDisplay (UserMsg, "USER Message2");
return (0);
}
/*========================================================== ======*\
----------------------user_initialize()--------------------- -------
\*========================================================== ======*/
int user_initialize (
int argc, /* Inp: Pro/E arg count */
char *argv[], /* Inp: Pro/E args */
char *version, /* Inp: Pro/E version */
char *build, /* Inp: Pro/E build date code */
wchar_t errbuf[80] ) /* Out: error message (opt)*/
{
ProError status;
uiCmdCmdId cmd_id1, cmd_id2;
/*---------------------------------------------------------- ------*\
Message file.
\*---------------------------------------------------------- ------*/
ProStringToWstring (UserMsg, "UserMsg.txt");
ProMessageDisplay (UserMsg, "USER Start");
/*---------------------------------------------------------- ------*\
Add a new menu (Gearing) to the menu bar (to the left of Help).
\*---------------------------------------------------------- ------*/
status = ProMenubarMenuAdd ("GearingMenu", "USER Gearing",
"Help", PRO_B_FALSE, UserMsg);
/*---------------------------------------------------------- ------*\
Add to the new menu.
\*---------------------------------------------------------- ------*/
//Click on "Create Gearing"
status = ProCmdActionAdd ("UserDispMsg1", (uiCmdCmdActFn)MiscAction1,
uiCmdPrioDefault, (uiCmdAccessFn)AccessGearing, PRO_B_TRUE, PRO_B_TRUE,
&cmd_id1);
//Click on "Create Table"
status = ProCmdActionAdd ("UserDispMsg2", (uiCmdCmdActFn)MiscAction2,
uiCmdPrioDefault, (uiCmdAccessFn)AccessTable, PRO_B_TRUE, PRO_B_TRUE,
&cmd_id2);
//create button "Create Gearing"
status = ProMenubarmenuPushbuttonAdd ("GearingMenu", "Create Gearing",
"USER Create Gearing", "USER Create Gearing Help.", NULL, PRO_B_TRUE,
cmd_id1, UserMsg);
//create button "Create Table"
status = ProMenubarmenuPushbuttonAdd ("GearingMenu", "Fill Table",
"USER Fill Table", "USER Fill Table Help.", "Create Gearing", PRO_B_TRUE,
cmd_id2, UserMsg);
return (0);
}
/*========================================================== ======*\
FUNCTION: user_terminate()
PURPOSE: ends Application
\*========================================================== ======*/
void user_terminate()
{
// clean up here if necessary
return(0);
}
Could you tell me where the problem is? As I've mentioned, I'm a rookie in Prp/Toolkit, so feel free to mention any mistakes or violations of programming rules etc. Do I get something wrong with the subfunctions or ProError?
Thank you very much!
w
I'm new in programming with Pro/Toolkit and I want to make a little program that can generate gear wheels and edit tables by reading parameters out of a loaded text file (quite similar to ProGearwheel...) I'm using Pro/E Wildfire 4.0.
Making the menus wasn't that problem, but now I got stuck at creating a dialog, though I've read the API (ProUIDialog and everything that goes with it), the helpfile (UserInterface...) and the examples over and over again.
The problem is that nothing happens when I click on button 1 in part mode (Create Gearing), except the Testing-Message is shown (which means that MiscAction1() works, doesn't it?). Button 2 (Create Table) works well (Testing-Message is shown) in drawing mode.
Due to reduce complexity I slimmed the dialog to a single OK button which closes the dialog
The dialog.res file should be correct and in the right directory (I need it in two languages).
The problem seems to be similar to this one:
http://www.mcadcentral.com/proe/forum/forum_posts.asp?TID=34 964&KW=dialog
But the only answer there didn't help me on.
Here is my code:
#include <ProToolkit.h>
#include <ProMenuBar.h>
#include <ProMessage.h>
//#include <ProUIDialog.h>&nb sp;
//#include <ProUIPushbutton.h>
#include <ProMdl.h>
#include <ProUI.h>
static ProFileName UserMsg;
static uiCmdCmdId cmd_id1, cmd_id2;
ProError MiscAction1(); //
ProError MiscAction2(); // do I need this here?
ProError CreateDialog(); //
/*========================================================== ===*\
FUNCTION: AccessGearing()
PURPOSE: Define the accessibility of "Create Gearing" menu button.
\*========================================================== ===*/
static uiCmdAccessState AccessGearing (uiCmdAccessMode access_mode)
{
ProMdl current;
ProMdlType type;
ProError status;
status = ProMdlCurrentGet (¤t);
if (status != PRO_TK_NO_ERROR)
return ACCESS_UNAVAILABLE;
status = ProMdlTypeGet (current, &type);
if (status != PRO_TK_NO_ERROR || type != PRO_MDL_PART)
return ACCESS_UNAVAILABLE;
return (ACCESS_AVAILABLE);
}
/*========================================================== ===*\
FUNCTION: AccessTable()
PURPOSE: Define the accessibility of "Create Table" menu button.
\*========================================================== ===*/
static uiCmdAccessState AccessTable (uiCmdAccessMode access_mode)
{
ProMdl current;
ProMdlType type;
ProError status;
status = ProMdlCurrentGet (¤t);
if (status != PRO_TK_NO_ERROR)
return ACCESS_UNAVAILABLE;
status = ProMdlTypeGet (current, &type);
if (status != PRO_TK_NO_ERROR || type != PRO_MDL_DRAWING)
return ACCESS_UNAVAILABLE;
return (ACCESS_AVAILABLE);
}
/*========================================================== ======*\
-------------------------CREATE GEARING-----------------------------
\*========================================================== ======*/
/*---------------------------------------------------------- ----------*\
FUNCTION : UserOKAction()
PURPOSE : Action function for the OK button
\*---------------------------------------------------------- ----------*/
ProError UserOKAction()
{
ProError status;
ProUIDialogExit("dialog", NULL);
return(status);
}
/*---------------------------------------------------------- ----------*\
FUNCTION : MiscAction1()
PURPOSE : Action after clicking on "Create Gearing"
\*---------------------------------------------------------- ----------*/
ProError MiscAction1()
{
ProError status;
status = CreateDialog();&nb sp;&nb sp;&nb sp; //nothing happens!
ProMessageDisplay (UserMsg, "USER Message1"); //is shown
return(status);
}
/*========================================================== ==========*\
FUNCTION : CreateDialog()
PURPOSE : Creates Dialog
\*========================================================== ==========*/
ProError CreateDialog ()
{
ProError status;
status = ProUIDialogCreate( "dialog", "dialog" );
status = ProUIDialogCloseActionSet( "dialog", (ProUIAction)UserOKAction, NULL );
status = ProUIPushbuttonActivateActionSet( "dialog", "OK", (ProUIAction)UserOKAction, NULL );
status = ProUIDialogActivate( "dialog", NULL );
//status = ProUIDialogAboveactivewindowSet( "dialog", PRO_B_TRUE); // Do I need this?
status = ProUIDialogDestroy( "dialog" );
return(status);
}
/*========================================================== ======*\
-------------------------CREATE TABLE------------------------------
\*========================================================== ======*/
/*========================================================== ======*\
FUNCTION: MiscAction2()
PURPOSE: Action after clicking on "Create Table"
\*========================================================== ======*/
int MiscAction2()
{
ProMessageDisplay (UserMsg, "USER Message2");
return (0);
}
/*========================================================== ======*\
----------------------user_initialize()--------------------- -------
\*========================================================== ======*/
int user_initialize (
int argc, /* Inp: Pro/E arg count */
char *argv[], /* Inp: Pro/E args */
char *version, /* Inp: Pro/E version */
char *build, /* Inp: Pro/E build date code */
wchar_t errbuf[80] ) /* Out: error message (opt)*/
{
ProError status;
uiCmdCmdId cmd_id1, cmd_id2;
/*---------------------------------------------------------- ------*\
Message file.
\*---------------------------------------------------------- ------*/
ProStringToWstring (UserMsg, "UserMsg.txt");
ProMessageDisplay (UserMsg, "USER Start");
/*---------------------------------------------------------- ------*\
Add a new menu (Gearing) to the menu bar (to the left of Help).
\*---------------------------------------------------------- ------*/
status = ProMenubarMenuAdd ("GearingMenu", "USER Gearing",
"Help", PRO_B_FALSE, UserMsg);
/*---------------------------------------------------------- ------*\
Add to the new menu.
\*---------------------------------------------------------- ------*/
//Click on "Create Gearing"
status = ProCmdActionAdd ("UserDispMsg1", (uiCmdCmdActFn)MiscAction1,
uiCmdPrioDefault, (uiCmdAccessFn)AccessGearing, PRO_B_TRUE, PRO_B_TRUE,
&cmd_id1);
//Click on "Create Table"
status = ProCmdActionAdd ("UserDispMsg2", (uiCmdCmdActFn)MiscAction2,
uiCmdPrioDefault, (uiCmdAccessFn)AccessTable, PRO_B_TRUE, PRO_B_TRUE,
&cmd_id2);
//create button "Create Gearing"
status = ProMenubarmenuPushbuttonAdd ("GearingMenu", "Create Gearing",
"USER Create Gearing", "USER Create Gearing Help.", NULL, PRO_B_TRUE,
cmd_id1, UserMsg);
//create button "Create Table"
status = ProMenubarmenuPushbuttonAdd ("GearingMenu", "Fill Table",
"USER Fill Table", "USER Fill Table Help.", "Create Gearing", PRO_B_TRUE,
cmd_id2, UserMsg);
return (0);
}
/*========================================================== ======*\
FUNCTION: user_terminate()
PURPOSE: ends Application
\*========================================================== ======*/
void user_terminate()
{
// clean up here if necessary
return(0);
}
Could you tell me where the problem is? As I've mentioned, I'm a rookie in Prp/Toolkit, so feel free to mention any mistakes or violations of programming rules etc. Do I get something wrong with the subfunctions or ProError?
Thank you very much!
w