cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

How to excute Creo Asycn. Mode with MFC UI

s5ucktion
1-Newbie

How to excute Creo Asycn. Mode with MFC UI

I'm trying to develop an asnyc application that is excuted by MFC GUI.


I made GUI with MFC and code like below.


It's compiled well. But Creo is not started.


How can i excute Creo asnyc application with MFC UI?


void CCALCDlg::OnBnClickedStart()
{


ProError status;


status = ProEngineerStart("D:\\ptc\\wildfire50\\bin\\proe.exe",");
}

3 REPLIES 3

Have you looked at the API wizard and set the required environment
variables?

Bob Monat
Jerand Technical Services, Inc.
bob@jerand.com
www.jerand.com
1-317-875-6087

On Wed, Jan 14, 2015 at 8:34 PM, Woojune Jang <->
wrote:

> I'm trying to develop an asnyc application that is excuted by MFC GUI.
>
> I made GUI with MFC and code like below.
>
> It's compiled well. But Creo is not started.
>
> How can i excute Creo asnyc application with MFC UI?
>
> void CCALCDlg:Smiley SurprisednBnClickedStart()
> {
>
> ProError status;
>
> status = ProEngineerStart("D:\ptc\wildfire50\bin\proe.exe",");
> }
>

Thank you for replying.


I already set env. PRO_COMM_MSG_EXE, PRO_DIRECTORY.


And I found somthing on google. But it's not working to me.


What I want to develop is..


Put some numbers in UI & push "Start" button, the 3D Modeldimension is changed to the numbersI put.With no graphics..



1. Execute Microsoft Visual Studio.
2. Select File/New. This displays the 'New' dialog.
3. From the 'New' dialog, select the 'Projects' tab
4. Select 'MFC AppWizard(exe)' from the list of project types
5. Enter your project name in the 'Project name:' box
6. Set the 'Location:' field by entering or browsing to the desired directory for the new project
7. The 'Create New Workspace' button should already be selected and Under 'Platforms:', Win32 should already be selected.
8. Select the 'OK' button. This brings up the 'MFC AppWizard - Step 1" screen,
Under 'What type of application would you like to create?', Select 'Dialog based'. (see footnote)
9. Select the 'Next' button. This brings up the 'MFC AppWizard - Step 2 of 4' screen.
Accept the default check box values, and enter your dialog title under 'Please enter a title for your dialog:'.
10. Select the 'Next' button. This brings up the 'MFC AppWizard - Step 3 of 4' screen.
Select your preference under 'Would you like to create source file comments?'
11. Under 'How would you like to use the MFC library', select 'As a statically linked library'.
12. Select the 'Next' button. This brings up the 'MFC AppWizard - Step 4 of 4' screen.
If you have a preference for the default class name, enter it in the 'Class name:" field.
13. Select the 'Finish' button to bring up the last screen.
On the last screen, select the 'OK' button. The wizard will then create the source code for the new project.


At this point you have completed creating the dialog - compile and run the application from under the Build menu pick by choosing "Execute <name.exe> !".
After successfully testing you application - please proceed to the next step.



--------------------------------------------------------------------------------


This step will instruct you on how to include the Pro/TOOLKIT functions to start Pro/ENGINEER from the application created above and display a message in the Pro/ENGINEER message window when the button in the MFC application is chosen.


I) Choose File, Open Choose the file <name_of_project>.cpp
scroll down this file to the line where you see the call InitInstance()


BOOL CTestPTKMFCApp::InitInstance()
{
AfxEnableControlContainer();


// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.


#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif


II) In this particular example we will add the call ProEngineerStart() before the MFC application starts its intialization.
#Define PRO_USE_VAR_ARGS, Include the Pro/TOOLKIT includes ProToolkit.h ProCore.h ProMessage.h ProUtil.h and declare two global variables status of type ProError and msgfile of type ProName.


// TestPTKMFC.cpp : Defines the class behaviors for the application.
//


#include "stdafx.h"
#include "TestPTKMFC.h"
#include "TestPTKMFCDlg.h"


#define PRO_USE_VAR_ARGS
#include <protoolkit.h>
#include <procore.h>
#include <promessage.h>
#include <proutil.h>


ProError status;
ProName msgfile;


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
.
.
.


III) Insert the ProEngineerStart. The first arguement to ProEngineerStart is the name of the Pro/ENGINEER startup script that has been configured on your system - make sure that the script is in your path i.e you are able to open a fresh MS-DOS command prompt and start Pro/ENGINEER by typing the argument by itself for example "proe2000i". If not add the directory that this script is located in to your PATH environment variable and try again.



BOOL CTestPTKMFCApp::InitInstance()
{
AfxEnableControlContainer();
status = ProEngineerStart("proe2000i",NULL);
if(status != PRO_TK_NO_ERROR)
{
printf("Error starting Pro/ENGINEER: %d\n", status );
exit(1);
}


// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.


#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
.
.
.


IV) Inorder to add the call back to shown the message in Pro/ENGINEER when the OK button is choosen, Scroll to the lines shown below and modify them as follows


.
.
.
CTestPTKMFCDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK


ProStringToWstring( msgfile, "gui_test.txt" );
status = ProMessageDisplay( msgfile, "button_selected" );


}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}

FV
17-Peridot
17-Peridot
(To:s5ucktion)

Hi all,



Woojune, it is not probably the best idea to use MFC for GUI in this day and age. You would be better of by using .NET WPF GUI or using Qt if you have to use 'pure' unmanagedC++. In any casePro/E async would be exactly the same and accessed from the GUI codevia DllImport directive. Thegood way to testorto learn is to compile async example which is included in Pro/Toolkit or OTK distribution and try toconnect to the resulting dll from the externalcode.

HIH.

Feliks.

Announcements
Business Continuity with Creo: Learn more about it here.

Top Tags