How to define types and constants in interface

My current Delphi application is compiled as an ActiveX control and is called from a WinForms project. We wish to replace the ActiveX wrapper with Hydra.

Currently the following is defined in the Delphi type library:

type
TxProblemFilter = TOleEnum;
const
pfAll = $00000000;
pfResolved = $00000001;
pfUnresolved = $00000002;
pfAuditTrail = $00000003;

IIntegraNotesDMRDisp = dispinterface
[’{FD0CD999-AA79-487E-B559-182156D1D03A}’]
procedure DisplayProblemList(FilterType: TxProblemFilter); safecall;

The WinForms project can expose these properties so that it understands the above declaration.

This may be fine for ActiveX, but when Hydra creates the corresponding interface in WinForms, types such as “TxProblemFilter” are obviously not recognized and the constants are not imported.

How would I rewrite this so that Hydra would include the type and constant definitions in the generated interface? If it is not possible I could simply convert the parameters to known types (integer) and pass an integer value, but it would be nice to have clear definitions for readability. Would enum types work in this case, and if so, could you give an example of how it would look in Delphi so that Hydra would successfully convert it into .NET?

Hello,

Unfortunately our importer tool currently does not support enums, so you will need to convert them manually. For example:

.NET side:

public enum MyEnum { First = 1, Second = 2, Third = 3 }

[Guid("F08EAC93-19BC-49F9-BE08-D821A40351A8")]
public interface ITestInterface : IHYCrossPlatformInterface
{
  void DoSomething(MyEnum Value);
}

public partial class Main : Form, IHYCrossPlatformHost, ITestInterface
{
[..]]
  public void DoSomething(MyEnum Value)
  {
    switch (Value)
    {
      case MyEnum.First:
        break;
      case MyEnum.Second:
        break;
      case MyEnum.Third:
        break;
      default:
        break;
    }
  }
}

Delphi side:

  TMyEnum = (meFirst = 1, meSecond = 2, meThird = 3);

  // Original Name: Host.ITestInterface
  ITestInterface = interface(IHYCrossPlatformInterface)
  ['{f08eac93-19bc-49f9-be08-d821a40351a8}']
    procedure DoSomething(const Value: TMyEnum); safecall;
  end;

procedure TNewVisualPlugin.DoSomething(const Value: MyEnum);
begin
  if Value = meFirst then
    ShowMessage('First');
end;

Hope this helps.

I think this will work well. Thank you.