with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IHTMLImageElementFactory_Interface is

   procedure Initialize (This : in out IHTMLImageElementFactory_Type) is
   begin
      Set_IID (This, IID_IHTMLImageElementFactory);
   end Initialize;

   function Pointer (This : IHTMLImageElementFactory_Type)
     return Pointer_To_IHTMLImageElementFactory
   is
   begin
      return To_Pointer_To_IHTMLImageElementFactory (Address (This));
   end Pointer;

   procedure Attach (This    : in out IHTMLImageElementFactory_Type;
                     Pointer : in     Pointer_To_IHTMLImageElementFactory)
   is
   begin
      Attach (This, GNATCOM.IInterface.To_Pointer_To_IUnknown
              (Pointer.all'Address));
   end Attach;

   function create
     (This                                 : IHTMLImageElementFactory_Type;
      width                                : GNATCOM.Types.VARIANT  := GNATCOM.Types.VARIANT_MISSING;
      height                               : GNATCOM.Types.VARIANT  := GNATCOM.Types.VARIANT_MISSING;
      Free                                 : Boolean := True)
     return Pointer_To_IHTMLImgElement
   is
       RetVal : aliased Pointer_To_IHTMLImgElement;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.create
         (Pointer (This),
          width,
          height,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (width);
               GNATCOM.IInterface.Free (height);
      
      end if;

      return RetVal;
   end create;

end MSHTML.IHTMLImageElementFactory_Interface;

