FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Help translating C++ to FWH
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 07:34 AM
I am still trying to access an exposed COM object from FWH (xHabour and Borland). I have some sample C++ code. Can anyone help translate for use in FWH?

The COM object has been installed and registered.

Regards,
James

EPSTIPNet::_ChargeNowPtr ptr("EPSTIPNet.gutil.Forms.ChargeNow");
	ptr->init();
	ptr->put_PM(EPSTIPNet::PAYMENTMODE_PayNow);
	ptr->put_CM(EPSTIPNet::CHARGEMODE_Sale);
	ptr->Show();
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 08:05 AM
James,

You can compile a C++ module and link the resulting OBJ to your application, as C and C++ are compatible.

To access C from C++ (to use [x]Harbour extend system) you have to declare the header files as extern "C":
extern "C" {
    #include <hbapi.h>
};
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 08:09 AM
As a example, you can do:
extern "C" {
#include <hbapi.h>
};

#include ...C++ header files...

HB_FUNC( TEST )
{
   EPSTIPNet::_ChargeNowPtr ptr("EPSTIPNet.gutil.Forms.ChargeNow"); 
   ptr->init(); 
   ptr->put_PM(EPSTIPNet::PAYMENTMODE_PayNow); 
   ptr->put_CM(EPSTIPNet::CHARGEMODE_Sale); 
   ptr->Show();
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 02:56 PM

Antonio,

I am not clear on what you are saying. Should your example be compiled as a PRG by FWH, or as a C file by Borland?

When I try to compile it as a PRG, I get a "syntax error at 'EXTERN.'"

How do I know which header files to include?

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 03:26 PM
Antonio,

I am making some progress! This code now works:

   oCharge:= CreateObject("EPSTIPNet.gutil.Forms.ChargeNow")
   oCharge:init()


Any ideas on how to translate these lines?

   ptr->put_PM(EPSTIPNet::PAYMENTMODE_PayNow);
   ptr->put_CM(EPSTIPNet::CHARGEMODE_Sale);
   ptr->Show();


Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 05:00 PM
oCharge:put_PM(PAYMENTMODE_PayNow)
oCharge:put_CM(CHARGEMODE_Sale)
oCharge:Show()


You have to search the values for PAYMENTMODE_PayNow and CHARGEMODE_Sale in the include files or in the docs of your COM object.

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 05:07 PM

James,

good news :-)

if you are able to manage from PRG level, as an OleAuto object, then it is much easier

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 05:21 PM

Enrico,

Would manifest constants only apply when used with FWH, or would they be needed with VB.NET, C#, and/or C++ too?

I cannot find any include files in the SDK files, nor is there any mention of them in the docs.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 06:05 PM

PAYMENTMODE_PayNow and CHARGEMODE_Sale are not manifest constants. They are probably enum data values inside EPSTIPNet class.

EMG

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 06:12 PM

Enrico,

>PAYMENTMODE_PayNow and CHARGEMODE_Sale are not manifest >constants. They are probably enum data values inside EPSTIPNet class.

OK, but I don't know what that means. How do I solve the problem?

As I guess you can tell, I know nothing about programming in C++.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 06:19 PM

You can't invent their values just as you can't invent manifest constants values. Sorry, I don't know where to find them. Probably they come directly from the .NET platform after the installation of the class module.

EMG

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 06:22 PM

Enrico,

Is the situation that other languages don't need these values, but with FWH we do? If other languages do need them, then how do they get them?

Is there some tool to allow us to get those values?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 06:32 PM
James Bott wrote:Enrico,

Is the situation that other languages don't need these values, but with FWH we do?


No, any language need all the values it manage.

James Bott wrote:If other languages do need them, then how do they get them?


Probably they are provided directly by the platform (.NET) after the installation of the class module. .NET is different from Win32.

James Bott wrote:Is there some tool to allow us to get those values?


Probably yes but I know nothing about .NET tools, sorry. And I'm not sure you can use that class in Win32 if it is written for .NET.

EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Help translating C++ to FWH
Posted: Fri Nov 07, 2008 11:53 PM
Here is some more positive news. I am able to get this code to run.

   oCharge:= CreateObject("EPSTIPNet.gutil.Forms.ChargeNow")
   oCharge:init()
   //oCharge:put_PM(PAYMENTMODE_PayNow)
   //oCharge:put_CM(CHARGEMODE_Sale)
   oCharge:Show()


A form quickly displays then vanishes, but at least this indicates that I am successfully instantiating the object. Now if I can just figure out the proper syntax and values for the two statements commented out.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Help translating C++ to FWH
Posted: Sat Nov 08, 2008 12:08 AM

James,

>
PAYMENTMODE_PayNow
CHARGEMODE_Sale
>

Make a search for them everywhere in the code and header files. They have to be there, somewhere.

They seem related to that specific COM object, not with .NET

regards, saludos

Antonio Linares
www.fivetechsoft.com