with GNATCOM.IInterface;

with GNATCOM.Errors;

package body MSHTML.IHTMLWindow3_Interface is

   procedure Initialize (This : in out IHTMLWindow3_Type) is
   begin
      Set_IID (This, IID_IHTMLWindow3);
   end Initialize;

   function Pointer (This : IHTMLWindow3_Type)
     return Pointer_To_IHTMLWindow3
   is
   begin
      return To_Pointer_To_IHTMLWindow3 (Address (This));
   end Pointer;

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

   function Get_screenLeft
     (This : IHTMLWindow3_Type)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_screenLeft
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_screenLeft;

   function Get_screenTop
     (This : IHTMLWindow3_Type)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_screenTop
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_screenTop;

   function attachEvent
     (This     : IHTMLWindow3_Type;
      event    : GNATCOM.Types.BSTR;
      pdisp    : GNATCOM.Types.Pointer_To_IDispatch;
      Free     : Boolean := True)
     return GNATCOM.Types.VARIANT_BOOL
   is
       RetVal : aliased GNATCOM.Types.VARIANT_BOOL;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.attachEvent
         (Pointer (This),
          event,
          pdisp,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (event);
      
      end if;

      return RetVal;
   end attachEvent;

   procedure detachEvent
     (This  : IHTMLWindow3_Type;
      event : GNATCOM.Types.BSTR;
      pdisp : GNATCOM.Types.Pointer_To_IDispatch;
      Free  : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.detachEvent
         (Pointer (This),
          event,
          pdisp));

      if Free then
               GNATCOM.IInterface.Free (event);
      
      end if;

   end detachEvent;

   function setTimeout
     (This       : IHTMLWindow3_Type;
      expression : access GNATCOM.Types.VARIANT :=
        GNATCOM.Types.PVARIANT_MISSING;
      msec       : Interfaces.C.long;
      language   : access GNATCOM.Types.VARIANT :=
        GNATCOM.Types.PVARIANT_MISSING)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.setTimeout
         (Pointer (This),
          expression,
          msec,
          language,
          RetVal'Unchecked_Access));

      return RetVal;
   end setTimeout;

   function setInterval
     (This       : IHTMLWindow3_Type;
      expression : access GNATCOM.Types.VARIANT :=
        GNATCOM.Types.PVARIANT_MISSING;
      msec       : Interfaces.C.long;
      language   : access GNATCOM.Types.VARIANT :=
        GNATCOM.Types.PVARIANT_MISSING)
     return Interfaces.C.long
   is
       RetVal : aliased Interfaces.C.long;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.setInterval
         (Pointer (This),
          expression,
          msec,
          language,
          RetVal'Unchecked_Access));

      return RetVal;
   end setInterval;

   procedure print
     (This : IHTMLWindow3_Type)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.print
         (Pointer (This)));

   end print;

   procedure Put_onbeforeprint
     (This : IHTMLWindow3_Type;
      p    : GNATCOM.Types.VARIANT;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_onbeforeprint
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_onbeforeprint;

   function Get_onbeforeprint
     (This : IHTMLWindow3_Type)
     return GNATCOM.Types.VARIANT
   is
       RetVal : aliased GNATCOM.Types.VARIANT;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_onbeforeprint
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_onbeforeprint;

   procedure Put_onafterprint
     (This : IHTMLWindow3_Type;
      p    : GNATCOM.Types.VARIANT;
      Free : Boolean := True)
   is
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Put_onafterprint
         (Pointer (This),
          p));

      if Free then
               GNATCOM.IInterface.Free (p);
      
      end if;

   end Put_onafterprint;

   function Get_onafterprint
     (This : IHTMLWindow3_Type)
     return GNATCOM.Types.VARIANT
   is
       RetVal : aliased GNATCOM.Types.VARIANT;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_onafterprint
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_onafterprint;

   function Get_clipboardData
     (This : IHTMLWindow3_Type)
     return Pointer_To_IHTMLDataTransfer
   is
       RetVal : aliased Pointer_To_IHTMLDataTransfer;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.Get_clipboardData
         (Pointer (This),
          RetVal'Unchecked_Access));

      return RetVal;
   end Get_clipboardData;

   function showModelessDialog
     (This     : IHTMLWindow3_Type;
      url      : GNATCOM.Types.BSTR;
      varArgIn : access GNATCOM.Types.VARIANT :=
        GNATCOM.Types.PVARIANT_MISSING;
      options  : access GNATCOM.Types.VARIANT :=
        GNATCOM.Types.PVARIANT_MISSING;
      Free     : Boolean := True)
     return Pointer_To_IHTMLWindow2
   is
       RetVal : aliased Pointer_To_IHTMLWindow2;
   begin
      GNATCOM.Errors.Error_Check
        (Pointer (This).Vtbl.showModelessDialog
         (Pointer (This),
          url,
          varArgIn,
          options,
          RetVal'Unchecked_Access));

      if Free then
               GNATCOM.IInterface.Free (url);
      
      end if;

      return RetVal;
   end showModelessDialog;

end MSHTML.IHTMLWindow3_Interface;

