/// <summary>
        /// Attempts to retreive a character position relative to the body
        /// content based on the character index.
        /// </summary>
        /// <param name="charindex"></param>
        /// <returns>Left and top coordinates of the character or -1,-1</returns>
        public tagPOINT GetPosFromCharIndex(int charindex)
        {
            IMarkupPointer impStart;
            IDisplayPointer idpCur;
            tagPOINT point = new tagPOINT();
            point.X = -1;
            point.Y = -1;

            if (m_pDoc2 == null)
                return point;

            if (m_pDisplayServices == null)
                return point;

            IHTMLElement elem = m_pDoc2.body;
            if (elem == null)
                return point;

            //Setup markup pointer
            m_pMarkupServices.CreateMarkupPointer(out impStart);

            //Position the markup pointer after beginning of the body tag
            impStart.MoveAdjacentToElement(elem, (int)ELEMENT_ADJACENCY.ELEM_ADJ_AfterBegin);

            // Create a display pointer from the markup pointer
            m_pDisplayServices.CreateDisplayPointer(out idpCur);

            //Move markup pointer accoring to charindex value
            for (int i = 0; i < charindex; i++)
            {
                impStart.MoveUnit((int)MOVEUNIT_ACTION.MOVEUNIT_NEXTCHAR);
            }
            //Move current display pointer to the beginning of target char
            idpCur.MoveToMarkupPointer(impStart, null);

            ILineInfo info = null;
            idpCur.GetLineInfo(out info);
            if (info != null)
            {
                point.X = info.x;
                point.Y = info.baseLine;
            }

            return point;
        }
Exemple #2
0
 public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo,
                                          [In, Out] tagPOINT pt, int cPoints);
        /// <summary>
        /// Attempts to retreive Caret position
        /// </summary>
        /// <returns></returns>
        public tagPOINT GetCaretPosition()
        {
            IHTMLCaret pcaret = null;
            tagPOINT point = new tagPOINT();
            point.X = -1;
            point.Y = -1;

            if (m_pDisplayServices == null)
                return point;

            m_pDisplayServices.GetCaret(out pcaret);
            if (pcaret != null)
            {
                //get the current caret position so we can reset it later
                pcaret.GetLocation(out point, true);
                //pcaret.MoveDisplayPointerToCaret(idpOriginal);
                //Hide caret
                //pcaret.Hide();
                //Moves Caret to a given displaypointer
                //pcaret.MoveCaretToPointer(idpCur, false, 1);
            }

            return point;
        }
 int IfacesEnumsStructsClasses.IDropTarget.Drop(System.Runtime.InteropServices.ComTypes.IDataObject pDataObj, uint grfKeyState, tagPOINT pt, ref uint pdwEffect)
 {
     if (pDataObj == null)
         return Hresults.S_OK;
     if (WBDragDrop != null)
     {
         DataObject obja = new DataObject(pDataObj);
         Point ppt = new Point(pt.X, pt.Y);
         WBDropEvent.SetParameters(grfKeyState, ppt, obja, pdwEffect);
         WBDragDrop(this, WBDropEvent);
         if (WBDropEvent.handled == true)
             pdwEffect = (uint)WBDropEvent.dropeffect;
     }
     return Hresults.S_OK;
 }
Exemple #5
0
 public static extern IntPtr SendMessage(HandleRef hWnd, uint msg,
                                         IntPtr wParam, ref tagPOINT lParam);
 int IfacesEnumsStructsClasses.IDropTarget.DragOver(uint grfKeyState, tagPOINT pt, ref uint pdwEffect)
 {
     if (WBDragOver != null)
     {
         Point ppt = new Point(pt.X, pt.Y);
         WBDragOverEvent.SetParameters(grfKeyState, ppt, pdwEffect);
         WBDragOver(this, WBDragOverEvent);
         if (WBDragOverEvent.handled == true)
             pdwEffect = (uint)WBDragOverEvent.dropeffect;
     }
     return Hresults.S_OK;
 }
        int IDocHostUIHandler.ShowContextMenu(uint dwID, ref tagPOINT pt, object pcmdtReserved, object pdispReserved)
        {
            //    return Hresults.S_OK; //Do not display context menu
            //    return Hresults.S_FALSE; //Default IE ctxmnu

            Point outpt = new Point(pt.X, pt.Y);
            //Raise event
            if (WBContextMenu != null)
            {
                ContextMenuEvent.SetParameters((WB_CONTEXTMENU_TYPES)dwID, outpt, pdispReserved);
                WBContextMenu(this, ContextMenuEvent);
                if (ContextMenuEvent.displaydefault == false) //Handled or don't display
                    return Hresults.S_OK;
                ContextMenuEvent.dispctxmenuobj = null;
            }
            return Hresults.S_FALSE;
        }
 int IDocHostShowUI.ShowHelp(IntPtr hwnd, string pszHelpFile, uint uCommand, uint dwData, tagPOINT ptMouse, object pDispatchObjectHit)
 {
     return Hresults.E_NOTIMPL;
 }
 public static extern IntPtr SendMessage(HandleRef hWnd, uint msg,
     IntPtr wParam, ref tagPOINT lParam);
Exemple #10
0
        int IDocHostUIHandler.ShowContextMenu(uint dwID, ref tagPOINT pt, object pcmdtReserved, object pdispReserved)
        {
            // return Hresults.S_OK; //Do not display context menu
            // return Hresults.S_FALSE; //Default IE ctxmnu

            //Raise event
            if (WBContextMenu != null)
            {
                //Screen coordinates
                Point outpt = new Point(pt.X, pt.Y);
                //Client coordinates
                Point clientpt = this.PointToClient(outpt);
                IHTMLElement elem = this.ElementFromPoint(clientpt.X, clientpt.Y);

                ContextMenuEvent.SetParameters((WB_CONTEXTMENU_TYPES)dwID, outpt, clientpt, elem, elem );
                WBContextMenu(this, ContextMenuEvent);
                if (ContextMenuEvent.displaydefault == false) //Handled or don't display
                    return Hresults.S_OK;
                ContextMenuEvent.dispctxmenuobj = null;
                ContextMenuEvent.ctxmenuelem = null;
            }
            return Hresults.S_FALSE;
        }