Hi,
I've developed an ActiveX in Visual C++ and I'm trying to use it in Delphi. When I have a return of a method in VC++ it doesn't work well in Delphi. For example, if the return is a boolean value, it always returns true in Delphi despite of the value I return in C++ (true or false). Another example, if I return a smallint (short in VC++) I always get the value 21 in Delphi, despite of the value in C++. I have a piece of code to exemplify the situation:
Piece of code using the ActiveX in Delphi:
procedure TForm1.FormatMemoryClick(Sender: TObject);
var
result1 : Integer;
result2 : Smallint;
begin
result1 := SonetoToolkit1.TestMethod(4, result2);
ShowMessage('Result1: ' + IntToStr(result1) + ' Result2: ' + IntToStr(result2));
end;
Piece of code of the ActiveX made in VC++:
short CSonetoToolkitCtrl::TestMethod(short testParam, short FAR* testReturn)
{
*testReturn = testParam + 3;
short a = testParam + 5;
CString msg;
msg.Format("In C++\ntestParam: %d\ntestReturn: %d\nretorn: %d", testParam, *testReturn, a);
AfxMessageBox(msg);
return a;
}
Results:
- Message Box in VC++
"In C++
testParam: 4
testReturn: 7
return: 9"
- Message Box in Delphi
"Result1: 21 Result2: 7"
Then, the returned value 9 in VC++ was turned to 21 in Delphi. If I change the input param (4 in this case) to 1, 2, 3, 5 or 6, for example, the returned value in Delphi is always 21 instead of 6, 7, 8, 10 or 11.
If anyone has the solution of this problem I will be very thankful.
Márcio Azevedo.
I've developed an ActiveX in Visual C++ and I'm trying to use it in Delphi. When I have a return of a method in VC++ it doesn't work well in Delphi. For example, if the return is a boolean value, it always returns true in Delphi despite of the value I return in C++ (true or false). Another example, if I return a smallint (short in VC++) I always get the value 21 in Delphi, despite of the value in C++. I have a piece of code to exemplify the situation:
Piece of code using the ActiveX in Delphi:
procedure TForm1.FormatMemoryClick(Sender: TObject);
var
result1 : Integer;
result2 : Smallint;
begin
result1 := SonetoToolkit1.TestMethod(4, result2);
ShowMessage('Result1: ' + IntToStr(result1) + ' Result2: ' + IntToStr(result2));
end;
Piece of code of the ActiveX made in VC++:
short CSonetoToolkitCtrl::TestMethod(short testParam, short FAR* testReturn)
{
*testReturn = testParam + 3;
short a = testParam + 5;
CString msg;
msg.Format("In C++\ntestParam: %d\ntestReturn: %d\nretorn: %d", testParam, *testReturn, a);
AfxMessageBox(msg);
return a;
}
Results:
- Message Box in VC++
"In C++
testParam: 4
testReturn: 7
return: 9"
- Message Box in Delphi
"Result1: 21 Result2: 7"
Then, the returned value 9 in VC++ was turned to 21 in Delphi. If I change the input param (4 in this case) to 1, 2, 3, 5 or 6, for example, the returned value in Delphi is always 21 instead of 6, 7, 8, 10 or 11.
If anyone has the solution of this problem I will be very thankful.
Márcio Azevedo.