Home COM GDI+ WebBrowser Data Access

IHTMLEditHost Interface

 

IID_IHTMLEditHost

{3050F6A0-98B5-11CF-BB82-00AA00BDCE0B}

 

 

This custom interface enables you to customize the way elements are resized and moved.

 

Documentation: IHTMLEditHost Interface

 

 

Methods in VTable order

IUnknown Methods

Description

QueryInterface

Returns pointers to supported interfaces.

AddRef

Increments reference count.

Release

Decrements reference count.

IHTMLEditHost Method

Description

SnapRect

Called by MSHTML whenever a selected element is resized or moved in the editor.

 

ITMLEditHost interface implementation

 


$IID_IHTMLEditHost = GUID$("{3050F6A0-98B5-11CF-BB82-00AA00BDCE0B}")

' ****************************************************************************************
' IHTMLEditHost interface virtual table
' ****************************************************************************************
TYPE IHTMLEditHostVtbl
   ' IUnknown methods
   pQueryInterface         AS DWORD          ' // QueryInterface method
   pAddRef                 AS DWORD          ' // AddRef method
   pRelease                AS DWORD          ' // Release method
   ' IHTMLEditHost method
   pSnapRect               AS DWORD          ' // SnapRect method
   ' Custom data
   pVtblAddr               AS DWORD          ' // Address of the virtual table
   cRef                    AS DWORD          ' // Reference count
END TYPE
' ****************************************************************************************

' ****************************************************************************************
' Builds the IHTMLEditHost Virtual Table
' Returns a cookie that is a pointer to a IHTMLEditHostVtbl structure.
' ****************************************************************************************
FUNCTION IHTMLEditHost_BuildVtbl () AS DWORD

   LOCAL pVtbl AS IHTMLEditHostVtbl PTR
   LOCAL pUnk AS IHTMLEditHostVtbl PTR

   pVtbl = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, SIZEOF(@pVtbl))
   IF pVtbl = 0 THEN EXIT FUNCTION

   @pVtbl.pQueryInterface         = CODEPTR(IHTMLEditHost_QueryInterface)
   @pVtbl.pAddRef                 = CODEPTR(IHTMLEditHost_AddRef)
   @pVtbl.pRelease                = CODEPTR(IHTMLEditHost_Release)

   @pVtbl.pSnapRect               = CODEPTR(IHTMLEditHost_SnapRect)

   @pVtbl.pVtblAddr               = pVtbl
   @pVtbl.cRef                    = 1

   pUnk = VARPTR(@pVtbl.pVtblAddr)
   FUNCTION = pUnk

END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' IHTMLEditHost_QueryInterface method
' Returns the IUnknown of our class and increments the reference counter.
' ****************************************************************************************
FUNCTION IHTMLEditHost_QueryInterface (BYVAL pCookie AS IHTMLEditHostVtbl PTR, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS LONG
   IF riid = $IID_IHTMLEditHost THEN
      ppvObj = pCookie
      INCR @@pCookie.cRef
      FUNCTION = %S_OK
   ELSE
      FUNCTION = %E_NOINTERFACE
   END IF
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' IHTMLEditHost_IUnknown_AddRef method
' Increments the reference counter.
' ****************************************************************************************
FUNCTION IHTMLEditHost_AddRef (BYVAL pCookie AS IHTMLEditHostVtbl PTR) AS DWORD
   INCR @@pCookie.cRef
   FUNCTION = @@pCookie.cRef
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' IHTMLEditHost_IUnknown_Release method
' Releases our class if there is only a reference to him and decrements the reference counter.
' ****************************************************************************************
FUNCTION IHTMLEditHost_Release (BYVAL pCookie AS IHTMLEditHostVtbl PTR) AS DWORD
   DECR @@pCookie.cRef
   FUNCTION = @@pCookie.cRef
   IF @@pCookie.cRef = 0 THEN
      IF ISTRUE @@pCookie.pVtblAddr THEN
         HeapFree(GetProcessHeap(), 0, BYVAL @@pCookie.pVtblAddr)
      END IF
   END IF
END FUNCTION
' ****************************************************************************************

' ****************************************************************************************
' Called by MSHTML whenever a selected element is resized or moved in the editor.
' ****************************************************************************************
FUNCTION IHTMLEditHost_SnapRect ( _
  BYVAL pCookie AS IHTMLEditHostVtbl PTR _
, BYVAL pIElement AS DWORD _
, BYREF prcNew AS RECT _
, BYVAL eHandle AS LONG _
) AS LONG

  ' Put your code here
  ' FUNCTION = %S_OK or an error value

END FUNCTION
' ****************************************************************************************
 

 

Page last updated on Monday, 03 April 2006 19:56:26 +0200