
with Ada.Unchecked_Conversion;
with Interfaces.C;  use Interfaces.C;
pragma Warnings(Off);
with System.Win32;
pragma Warnings(On);

with GNATCOM.Types;  use GNATCOM.Types;
with GNATCOM.GUID;
with GWindows.Types; use GWindows.Types;
with GNATOCX_Site;   use GNATOCX_Site;
with GNATOCX;        use GNATOCX;
with DocObj;         use DocObj;
with OleIdl;         use OleIdl;

package MSHTMLHST is
   -- package MSHTMLHST.IDocHostUIHandler_Interface is
   -- MSHTMLHST-IDocHostUIHandler_Interface.ads
   -- MSHTMLHST-IDocHostUIHandler_Interface.adb
   -- package MSHTMLHST.ICustomDoc_Interface is
   -- MSHTMLHST-ICustomDoc_Interface.ads
   -- MSHTMLHST-ICustomDoc_Interface.adb
   -- package MSHTMLHST.IDocHostUIHandler_Object is
   -- MSHTMLHST-IDocHostUIHandler_Object.ads
   -- MSHTMLHST-IDocHostUIHandler_Object.adb

   type IHostDialogHelper;
   type IDocHostUIHandler;
   type ICustomDoc;
--     type IDocHostUIHandler2;
--     type IDocHostShowUI;
--     type IClassFactoryEx;
--     type IHTMLOMWindowServices;

   type Pointer_To_IHostDialogHelper is access all IHostDialogHelper;
   type Pointer_To_IDocHostUIHandler is access all IDocHostUIHandler;
   type Pointer_To_ICustomDoc is access all ICustomDoc;
--     type Pointer_To_IDocHostUIHandler2 is access all IDocHostUIHandler2;
--     type Pointer_To_IDocHostShowUI is access all IDocHostShowUI;
--     type Pointer_To_IClassFactoryEx is access all IClassFactoryEx;
--     type Pointer_To_IHTMLOMWindowServices is access all IHTMLOMWindowServices;

   CONTEXT_MENU_DEFAULT    : constant := 0;
   CONTEXT_MENU_IMAGE      : constant := 1;
   CONTEXT_MENU_CONTROL    : constant := 2;
   CONTEXT_MENU_TABLE      : constant := 3;
   -- in browse mode
   CONTEXT_MENU_TEXTSELECT : constant := 4;
   CONTEXT_MENU_ANCHOR     : constant := 5;
   CONTEXT_MENU_UNKNOWN    : constant := 6;
   --;begin_internal
   -- These 2 are mapped to IMAGE for the public
   CONTEXT_MENU_IMGDYNSRC  : constant := 7;
   CONTEXT_MENU_DEBUG      : constant := 8;
   --;end_internal
   CONTEXT_MENU_VSCROLL    : constant := 9;
   CONTEXT_MENU_HSCROLL    : constant := 10;
   CONTEXT_MENU_MEDIA      : constant := 11;
   --;begin_internal
   CONTEXT_MENU_ENTITY     : constant := 12;
   --;end_internal

   -- enum tagDOCHOSTUIFLAG
   DOCHOSTUIFLAG_DIALOG	                        : DWORD := 16#1#;
   DOCHOSTUIFLAG_DISABLE_HELP_MENU	        : DWORD := 16#2#;
   DOCHOSTUIFLAG_NO3DBORDER	                : DWORD := 16#4#;
   DOCHOSTUIFLAG_SCROLL_NO	                : DWORD := 16#8#;
   DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE	: DWORD := 16#10#;
   DOCHOSTUIFLAG_OPENNEWWIN	                : DWORD := 16#20#;
   DOCHOSTUIFLAG_DISABLE_OFFSCREEN	        : DWORD := 16#40#;
   DOCHOSTUIFLAG_FLAT_SCROLLBAR	                : DWORD := 16#80#;
   DOCHOSTUIFLAG_DIV_BLOCKDEFAULT	        : DWORD := 16#100#;
   DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY	: DWORD := 16#200#;
   DOCHOSTUIFLAG_OVERRIDEBEHAVIORFACTORY	: DWORD := 16#400#;
   DOCHOSTUIFLAG_CODEPAGELINKEDFONTS	        : DWORD := 16#800#;
   DOCHOSTUIFLAG_URL_ENCODING_DISABLE_UTF8	: DWORD := 16#1000#;
   DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8	: DWORD := 16#2000#;
   DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE	: DWORD := 16#4000#;
   DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION	: DWORD := 16#10000#;
   DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION	: DWORD := 16#20000#;
   DOCHOSTUIFLAG_THEME	                        : DWORD := 16#40000#;
   DOCHOSTUIFLAG_NOTHEME	                : DWORD := 16#80000#;
   DOCHOSTUIFLAG_NOPICS	                        : DWORD := 16#100000#;
   DOCHOSTUIFLAG_NO3DOUTERBORDER	        : DWORD := 16#200000#;
   DOCHOSTUIFLAG_DISABLE_EDIT_NS_FIXUP	        : DWORD := 16#400000#;
   DOCHOSTUIFLAG_LOCAL_MACHINE_ACCESS_CHECK	: DWORD := 16#800000#;
   DOCHOSTUIFLAG_DISABLE_UNTRUSTEDPROTOCOL	: DWORD := 16#1000000#;
   DOCHOSTUIFLAG_HOST_NAVIGATES	                : DWORD := 16#2000000#;
   DOCHOSTUIFLAG_ENABLE_REDIRECT_NOTIFICATION	: DWORD := 16#4000000#;
   DOCHOSTUIFLAG_USE_WINDOWLESS_SELECTCONTROL	: DWORD := 16#8000000#;
   DOCHOSTUIFLAG_USE_WINDOWED_SELECTCONTROL	: DWORD := 16#10000000#;
   DOCHOSTUIFLAG_ENABLE_ACTIVEX_INACTIVATE_MODE : DWORD := 16#20000000#;
   DOCHOSTUIFLAG_DPI_AWARE	                : DWORD := 16#40000000#;
   -- DOCHOSTUIFLAG
   DOCHOSTUIFLAG_BROWSER : DWORD :=
     DOCHOSTUIFLAG_DISABLE_HELP_MENU or DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE;

   MENUEXT_SHOWDIALOG    : constant := 16#1#;

   HTMLDLG_NOUI                 : DWORD := 16#0010#;
   HTMLDLG_MODAL                : DWORD := 16#0020#;
   HTMLDLG_MODELESS             : DWORD := 16#0040#;
   HTMLDLG_PRINT_TEMPLATE       : DWORD := 16#0080#;
   HTMLDLG_VERIFY               : DWORD := 16#0100#;
   HTMLDLG_ALLOW_UNKNOWN_THREAD : DWORD := 16#0200#;

   PRINT_DONTBOTHERUSER         : DWORD := 16#01#;
   PRINT_WAITFORCOMPLETION      : DWORD := 16#02#;

   CMDID_SCRIPTSITE_URL             : constant := 0;
   CMDID_SCRIPTSITE_HTMLDLGTRUST    : constant := 1;
   CMDID_SCRIPTSITE_SECSTATE        : constant := 2;
   CMDID_SCRIPTSITE_SID             : constant := 3;
   CMDID_SCRIPTSITE_TRUSTEDDOC      : constant := 4;
   CMDID_SCRIPTSITE_SECURITY_WINDOW : constant := 5;
   CMDID_SCRIPTSITE_NAMESPACE       : constant := 6;
   CMDID_SCRIPTSITE_IURI            : constant := 7;
   CMDID_HOSTCONTEXT_URL            : constant := 8;
   CMDID_SCRIPTSITE_ALLOWRECOVERY   : constant := 9;
   CMDID_SCRIPTSITE_BASEIURI        : constant := 10;

   -- enum tagDOCHOSTUITYPE
   DOCHOSTUITYPE_BROWSE : constant := 0;
   DOCHOSTUITYPE_AUTHOR	: constant := 1;
   -- DOCHOSTUITYPE

   -- enum tagDOCHOSTUIDBLCLK
   DOCHOSTUIDBLCLK_DEFAULT	  : constant := 0;
   DOCHOSTUIDBLCLK_SHOWPROPERTIES : constant := 1;
   DOCHOSTUIDBLCLK_SHOWCODE	  : constant := 2;
   -- DOCHOSTUIDBLCLK

   type DOCHOSTUIINFO is record
      cbSize     : Integer;
      dwFlags    : DWORD;
      pchHostCss : LPWSTR;
      pchHostNS  : LPWSTR;
   end record;


   CLSID_HostDialogHelper : aliased GNATCOM.Types.GUID :=
     GNATCOM.GUID.To_GUID ("{53DEC138-A51E-11d2-861E-00C04FA35C89}");

   type af_IHostDialogHelper_QueryInterface is access
     function (This   : access IHostDialogHelper;
	       riid   : Pointer_To_GUID;
	       ppvObj : Pointer_To_Pointer_To_Void
	      ) return HRESULT;
   pragma Convention (StdCall, af_IHostDialogHelper_QueryInterface);

   type af_IHostDialogHelper_AddRef is access
     function (This : access IHostDialogHelper)
	       return unsigned_long;
   pragma Convention (StdCall, af_IHostDialogHelper_AddRef);

   type af_IHostDialogHelper_Release is access
     function (This : access IHostDialogHelper)
	       return unsigned_long;
   pragma Convention (StdCall, af_IHostDialogHelper_Release);

   type af_IHostDialogHelper_ShowHTMLDialog is access
     function (This         : access IHostDialogHelper;
	       hwndParent   : HWND;
	       pMk          : access GNATOCX.IMoniker;
	       pvarArgIn    : access VARIANT;
	       pchOptions   : access wchar_t;
	       pvarArgOut   : access VARIANT;
	       punkHost     : access IUnknown
	      ) return HRESULT;
   pragma Convention (StdCall, af_IHostDialogHelper_ShowHTMLDialog);

   type IHostDialogHelperVtbl;
   type Pointer_To_IHostDialogHelperVtbl is access all IHostDialogHelperVtbl;

   type IHostDialogHelper is
      record
	 Vtbl : Pointer_To_IHostDialogHelperVtbl;
      end record;
   pragma Convention (C_Pass_By_Copy, IHostDialogHelper);

   type IHostDialogHelperVtbl is
      record
	 QueryInterface         : af_IHostDialogHelper_QueryInterface;
	 AddRef                 : af_IHostDialogHelper_AddRef;
	 Release                : af_IHostDialogHelper_Release;
	 ShowHTMLDialog         : af_IHostDialogHelper_ShowHTMLDialog;
      end record;
   pragma Convention (C_Pass_By_Copy, IHostDialogHelperVtbl);


   IID_IDocHostUIHandler : aliased GNATCOM.Types.GUID :=
     GNATCOM.GUID.To_GUID ("{BD3F23C0-D43E-11CF-893B-00AA00BDCE1A}");

   type af_IDocHostUIHandler_QueryInterface is access
     function (
	       This   : Pointer_To_IDocHostUIHandler;
	       riid   : Pointer_To_GUID;
	       ppvObj : Pointer_To_Pointer_To_Void
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_QueryInterface);

   type af_IDocHostUIHandler_AddRef is access
     function (This : Pointer_To_IDocHostUIHandler)
	       return unsigned_long;
   pragma Convention (StdCall, af_IDocHostUIHandler_AddRef);

   type af_IDocHostUIHandler_Release is access
     function (This : Pointer_To_IDocHostUIHandler)
	       return unsigned_long;
   pragma Convention (StdCall, af_IDocHostUIHandler_Release);

   type af_IDocHostUIHandler_ShowContextMenu is access
     function (
	       This : Pointer_To_IDocHostUIHandler;
	       dwID : DWORD;
	       ppt  : access Point_Type;
	       pcmdtReserved : access IUnknown;
	       pdispReserved : access IDispatch
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_ShowContextMenu);

   type af_IDocHostUIHandler_GetHostInfo is access
     function (
	       This  : Pointer_To_IDocHostUIHandler;
	       pInfo : access DOCHOSTUIINFO
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_GetHostInfo);

   type af_IDocHostUIHandler_ShowUI is access
     function (
	       This           : Pointer_To_IDocHostUIHandler;
	       dwID           : DWORD;
	       pActiveObject  : access IOleInPlaceActiveObject;
	       pCommandTarget : access IOleCommandTarget;
	       pFrame         : access IOleInPlaceFrame;
	       pDoc           : access IOleInPlaceUIWindow
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_ShowUI);

   type af_IDocHostUIHandler_HideUI is access
     function (
	       This           : Pointer_To_IDocHostUIHandler
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_HideUI);

   type af_IDocHostUIHandler_UpdateUI is access
     function (
	       This           : Pointer_To_IDocHostUIHandler
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_UpdateUI);

   type af_IDocHostUIHandler_EnableModeless is access
     function (
	       This           : Pointer_To_IDocHostUIHandler;
	       fEnable        : System.Win32.BOOL
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_EnableModeless);

   type af_IDocHostUIHandler_OnDocWindowActivate is access
     function (
	       This           : Pointer_To_IDocHostUIHandler;
	       fActivate      : System.Win32.BOOL
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_OnDocWindowActivate);

   type af_IDocHostUIHandler_OnFrameWindowActivate is access
     function (
	       This           : Pointer_To_IDocHostUIHandler;
	       fActivate      : System.Win32.BOOL
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_OnFrameWindowActivate);

   type af_IDocHostUIHandler_ResizeBorder is access
     function (
	       This           : Pointer_To_IDocHostUIHandler;
	       prcBorder      : access GNATOCX.RECT;
	       pUIWindow      : access IOleInPlaceUIWindow;
	       fRameWindow    : System.Win32.BOOL
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_ResizeBorder);

   type af_IDocHostUIHandler_TranslateAccelerator is access
     function (
	       This           : Pointer_To_IDocHostUIHandler;
	       lpMsg          : access GNATOCX.MSG;
	       pguidCmdGroup  : access GNATCOM.Types.GUID;
	       nCmdID         : DWORD
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_TranslateAccelerator);

   type af_IDocHostUIHandler_GetOptionKeyPath is access
     function (
	       This           : Pointer_To_IDocHostUIHandler;
	       pchKey         : access LPWSTR
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_GetOptionKeyPath);

   type af_IDocHostUIHandler_GetDropTarget is access
     function (
	       This           : Pointer_To_IDocHostUIHandler;
	       pDropTarget    : access IDropTarget;
	       ppDropTarget   : access Pointer_To_IDropTarget
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_GetDropTarget);

   type af_IDocHostUIHandler_GetExternal is access
     function (
	       This           : Pointer_To_IDocHostUIHandler;
	       ppDispatch     : access Pointer_To_IDispatch
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_GetExternal);

   type af_IDocHostUIHandler_TranslateUrl is access
     function (
	       This           : Pointer_To_IDocHostUIHandler;
	       dwTranslate    : DWORD;
	       pchURLIn       : LPWSTR;
	       ppchURLOut     : access LPWSTR
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_TranslateUrl);

   type af_IDocHostUIHandler_FilterDataObject is access
     function (
	       This           : Pointer_To_IDocHostUIHandler;
	       pDO            : access IDataObject;
	       ppDORet        : access Pointer_TO_IDataObject
	      ) return HRESULT;
   pragma Convention (StdCall, af_IDocHostUIHandler_FilterDataObject);

   type IDocHostUIHandlerVtbl;
   type Pointer_To_IDocHostUIHandlerVtbl is access all IDocHostUIHandlerVtbl;

   type IDocHostUIHandler is
      record
	 Vtbl : Pointer_To_IDocHostUIHandlerVtbl;
      end record;
   pragma Convention (C_Pass_By_Copy, IDocHostUIHandler);

   type IDocHostUIHandlerVtbl is
      record
	 QueryInterface         : af_IDocHostUIHandler_QueryInterface;
	 AddRef                 : af_IDocHostUIHandler_AddRef;
	 Release                : af_IDocHostUIHandler_Release;
	 ShowContextMenu        : af_IDocHostUIHandler_ShowContextMenu;
	 GetHostInfo            : af_IDocHostUIHandler_GetHostInfo;
	 ShowUI                 : af_IDocHostUIHandler_ShowUI;
	 HideUI                 : af_IDocHostUIHandler_HideUI;
	 UpdateUI               : af_IDocHostUIHandler_UpdateUI;
	 EnableModeless         : af_IDocHostUIHandler_EnableModeless;
	 OnDocWindowActivate    : af_IDocHostUIHandler_OnDocWindowActivate;
	 OnFrameWindowActivate  : af_IDocHostUIHandler_OnFrameWindowActivate;
	 ResizeBorder           : af_IDocHostUIHandler_ResizeBorder;
	 TranslateAccelerator   : af_IDocHostUIHandler_TranslateAccelerator;
	 GetOptionKeyPath       : af_IDocHostUIHandler_GetOptionKeyPath;
	 GetDropTarget          : af_IDocHostUIHandler_GetDropTarget;
	 GetExternal            : af_IDocHostUIHandler_GetExternal;
	 TranslateUrl           : af_IDocHostUIHandler_TranslateUrl;
	 FilterDataObject       : af_IDocHostUIHandler_FilterDataObject;
      end record;
   pragma Convention (C_Pass_By_Copy, IDocHostUIHandlerVtbl);

   function To_Pointer_To_IDocHostUIHandler is
     new Ada.Unchecked_Conversion
       (GNATCOM.Types.Pointer_To_Void, Pointer_To_IDocHostUIHandler);


   IID_ICustomDoc : aliased GNATCOM.Types.GUID :=
     GNATCOM.GUID.To_GUID ("{3050f3f0-98b5-11cf-bb82-00aa00bdce0b}");

   type af_ICustomDoc_QueryInterface is access
     function (This   : access ICustomDoc;
	       riid   : Pointer_To_GUID;
	       ppvObj : Pointer_To_Pointer_To_Void
	      ) return HRESULT;
   pragma Convention (StdCall, af_ICustomDoc_QueryInterface);

   type af_ICustomDoc_AddRef is access
     function (This : access ICustomDoc)
	       return unsigned_long;
   pragma Convention (StdCall, af_ICustomDoc_AddRef);

   type af_ICustomDoc_Release is access
     function (This : access ICustomDoc)
	       return unsigned_long;
   pragma Convention (StdCall, af_ICustomDoc_Release);

   type af_ICustomDoc_SetUIHandler is access
     function (This         : access ICustomDoc;
	       pUIHandler   : Pointer_To_IDocHostUIHandler
	      ) return HRESULT;
   pragma Convention (StdCall, af_ICustomDoc_SetUIHandler);

   type ICustomDocVtbl;
   type Pointer_To_ICustomDocVtbl is access all ICustomDocVtbl;

   type ICustomDoc is
      record
	 Vtbl : Pointer_To_ICustomDocVtbl;
      end record;
   pragma Convention (C_Pass_By_Copy, ICustomDoc);

   type ICustomDocVtbl is
      record
	 QueryInterface         : af_ICustomDoc_QueryInterface;
	 AddRef                 : af_ICustomDoc_AddRef;
	 Release                : af_ICustomDoc_Release;
	 SetUIHandler           : af_ICustomDoc_SetUIHandler;
      end record;
   pragma Convention (C_Pass_By_Copy, ICustomDocVtbl);

   function To_Pointer_To_ICustomDoc is
     new Ada.Unchecked_Conversion
       (GNATCOM.Types.Pointer_To_Void, Pointer_To_ICustomDoc);

end MSHTMLHST;
