
with GNATCOM.Dispinterface;                   use GNATCOM.Dispinterface;
with GNATCOM.Create.COM_Interface;            use GNATCOM.Create.COM_Interface;
with GNATCOM.Events;                          use GNATCOM.Events;
with GWindows;                                use GWindows;
with GWindows.Windows;                        use GWindows.Windows;
with GWindows.ActiveX;                        use GWindows.ActiveX;

with MSHTML;                                  use MSHTML;
with MSHTML.IHTMLDocument2_Interface;         use MSHTML.IHTMLDocument2_Interface;
with MSHTML.IHTMLElement_Interface;           use MSHTML.IHTMLElement_Interface;
with MSHTML.HTMLDocumentEvents_Events;        use MSHTML.HTMLDocumentEvents_Events;
with MSHTML.IHTMLInputElement_Interface;      use MSHTML.IHTMLInputElement_Interface;
with MSHTML.IHTMLImgElement_Interface;        use MSHTML.IHTMLImgElement_Interface;
with MSHTML.IHTMLEventObj_Interface;          use MSHTML.IHTMLEventObj_Interface;
with MSHTML.IHTMLElementCollection_Interface; use MSHTML.IHTMLElementCollection_Interface;
with SHDocVw;
with SHDocVw.IWebBrowser2_Interface;          use SHDocVw.IWebBrowser2_Interface;

package HtmlForm is

   type HtmlForm_type is tagged private;
   type Pointer_To_HtmlForm_type is access all HtmlForm_type;
   type HTML_Event_Type is new HTMLDocumentEvents_Event with
      record
	 pHtmlForm : Pointer_To_HtmlForm_type := null;
      end record;
   procedure onclick (This : HTML_Event_Type);
   type af_OnEventProc is access
     procedure(
	       oEventObj : in out IHTMLEventObj_Type
	      );
   type Event_Descriptor is
      record
	 m_usElementName : GString_Unbounded;
	 m_pOnEventProc  : af_OnEventProc;
      end record;
   type Event_Descriptors is array (Positive range <>) of Event_Descriptor;
   type Pointer_To_Event_Descriptors is access all Event_Descriptors;

   procedure Create(
                    This           : in out HtmlForm_type;
                    pActivXControl : ActiveX_Access;
		    oHtmlControl   : IWebBrowser2_Type;
		    pOnClickEvents : Pointer_To_Event_Descriptors := null
                   );
   procedure GetElement(
			This        : in     HtmlForm_type;
			sElementId  : in     GString;
			oElement    : in out Dispinterface_Type;
			bCollection : out    Boolean
		       );
   procedure GetElement(
			This       : in     HtmlForm_type;
			sElementId : in     GString;
			oElement   : in out IHTMLElement_Type
                       );
   function Get_title(This : HtmlForm_type) return GString;
   function GetInnerText(This : IHTMLElement_Type) return GString;
   procedure SetInnerText(
			  This   : in out IHTMLElement_Type;
			  sValue : in     GString
			 );
   function GetInnerHTML(This : IHTMLElement_Type) return GString;
   procedure SetInnerHTML(
			  This   : in out IHTMLElement_Type;
			  sValue : in     GString
			 );
   function GetInnerText(
			 This       : HtmlForm_type;
			 sElementId : GString
			) return GString;
   procedure SetInnerText(
			  This       : in out HtmlForm_type;
			  sElementId : GString;
			  sValue     : GString
			 );
   function GetInnerHTML(
			 This       : HtmlForm_type;
			 sElementId : GString
			) return GString;
   procedure SetInnerHTML(
			  This       : in out HtmlForm_type;
			  sElementId : GString;
			  sValue     : GString
			 );
   function GetInputValue(This : IHTMLInputElement_Type) return GString;
   procedure SetInputValue(
			   This   : in out IHTMLInputElement_Type;
			   sValue : in     GString
			  );
   function GetInputValue(
			  This       : HtmlForm_type;
			  sElementId : GString
			 ) return GString;
   procedure SetInputValue(
			   This       : in out HtmlForm_type;
			   sElementId : GString;
			   sValue     : GString
			  );
   function GetImgSrc(This : IHTMLImgElement_Type) return GString;
   procedure SetImgSrc(
		       This   : in out IHTMLImgElement_Type;
		       sValue : in     GString
		      );
   function GetImgSrc(
		      This       : HtmlForm_type;
		      sElementId : GString
		     ) return GString;
   procedure SetImgSrc(
		       This       : in out HtmlForm_type;
		       sElementId : GString;
		       sValue     : GString
		      );
   procedure UpdateData(
			This       : in out HtmlForm_type;
			bReadOp    : Boolean := False
		       );
   procedure DDX_DHtml_ElementInnerHtml(
					This       : in out HtmlForm_type;
					sElementId : GString;
					usValue    : in out GString_Unbounded;
					bReadOp    : Boolean
				       );
   procedure DDX_DHtml_ElementInnerText(
					This       : in out HtmlForm_type;
					sElementId : GString;
					usValue    : in out GString_Unbounded;
					bReadOp    : Boolean
				       );
   procedure DDX_DHtml_InputValue(
				  This       : in out HtmlForm_type;
				  sElementId : GString;
				  usValue    : in out GString_Unbounded;
				  bReadOp    : Boolean
				 );
   procedure DDX_DHtml_Img_Src(
			       This       : in out HtmlForm_type;
			       sElementId : GString;
			       usValue    : in out GString_Unbounded;
			       bReadOp    : Boolean
			      );
private
   type HtmlForm_type is tagged
      record
         m_oHtmlControl       : IWebBrowser2_Type;
         m_pActivXControl     : ActiveX_Access;
         m_oHtmlDocument      : IHTMLDocument2_Type;
	 m_HTML_Event_Object  : aliased HTML_Event_Type;
	 m_HTML_Event         : Pointer_To_COM_Interface_Type;
	 m_HTML_Events_CPoint : IConnectionPoint_Type;
	 m_pOnClickEvents     : Pointer_To_Event_Descriptors := null;
      end record;
end HtmlForm;
