-1

There is an old project that I need to recompile to XE5 trying to aavoid the weird Twebbrowser errors that the original D7 component brings. The code bellow works great on D7 but not on XE5.

    function GetFrame(FrameNo: Integer; WB: TWEbbrowser): IWebbrowser2;
    var
      OleContainer: IOleContainer;
      enum: IEnumUnknown;
      unk: IUnknown;
      Fetched: PLongint;
    begin
      while WB.ReadyState <> READYSTATE_COMPLETE do
        Application.ProcessMessages;
      if Assigned(WB.document) then
      begin
        Fetched := nil;
        OleContainer := WB.Document as IOleContainer;
        OleContainer.EnumObjects(OLECONTF_EMBEDDINGS, Enum);
        Enum.Skip(FrameNo);
        Enum.Next(1, Unk, Fetched);
        Result := Unk as IWebbrowser2;
      end
      else
        Result := nil;
    end;

I've checked and the parameters for EnumObjects are the same on both versions but XE5 says "E2033. Types of actual and formal var parameters must be identical". Any idea how I can recompile this puppy? Thanks. Peace!

1 Answers1

4

For a variable parameter, the actual argument must be of the exact type of the formal parameter.

If you get the error I can assume that type of your enum variable is not of type : ActiveX.IEnumUnknown, so you can try to change this line in the variable declaration section :

enum: IEnumUnknown;

to :

enum: ActiveX.IEnumUnknown;
aleroot
  • 71,077
  • 30
  • 176
  • 213
  • Yes. You are right. Thank you very much Aleroot! Peace! – Julienne Maurici Sep 21 '14 at 18:22
  • 1
    Perhaps a deeper investigation would be wise here. I'd want to know where this other `IEnumUnknown` is declared, and why it is hiding the other one. Ideally I'd prefer to deal with the problem by removing the faux `IEnumUnknown` from scope if at all possible. – David Heffernan Sep 22 '14 at 08:12
  • I agree @David. The other IEnumUnknown comes from MSHTML. The change proposed by Aleroot made the code recompile flawlessly but the app is not working as expected. I use it to fill a government form that is open only a few hours per day so I was able to test it just now. I need to investigate more. Thank you. – Julienne Maurici Sep 22 '14 at 13:37