Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Web Browser control
Message
De
21/01/2022 08:39:13
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Titre:
Web Browser control
Divers
Thread ID:
01683307
Message ID:
01683307
Vues:
65
Hello,

I have a form with Microsoft Webbrowser activex control which works as HTML editor. There are templates for remarks (plain text), which user selects and it then paste in browser control.
The text in remark may has multiple blocks of underscores like "____________________" it should be find and selected by pressing TAB key so user can fill the blanks and move to the next blank by just pressing TAB.
I have implemented an eventhandler (HTMLDocumentEvents2 interface) to trap TAB key in keypress/keyup/keydown events, following the code I am using to achive this.

Tried Method 1
PROCEDURE HTMLDocumentEvents2_onkeyup(pEvtObj AS VARIANT) AS VOID
IF This.nKeyCode = 9 && Value set in keydown event.
This.nKeyCode = 0
LOCAL nMoveValue, nPos
nMoveValue = IIF(THIS.lShiftPressed,-1,1)
IF ISNULL(THIS.oRange)
THIS.oRange = THIS.oHTMLControl.Cont.TaxIE.Document.Selection.CreateRange()
THIS.oRange.Expand("textedit")
ELSE
THIS.oRange.Collapse(.F.)
ENDIF

IF THIS.oRange.FindText("__", 1, IIF(THIS.lShiftPressed,1,0))
THIS.oRange.Select()
THIS.oRange.Expand("word")

DO WHILE (" "$THIS.oRange.text)
THIS.oRange.moveEnd("character", -1)
ENDDO

THIS.oRange.Select()
THIS.oRange.ScrollIntoView()
ENDIF
ENDIF
ENDPROC



Tried Method 2
IF This.nKeyCode = 9 &&THIS.lTabPressed
This.nKeyCode = 0
LOCAL nMoveValue, nPos
nMoveValue = IIF(THIS.lShiftPressed,-1,1)

IF ISNULL(THIS.oRange)
THIS.oRange = THIS.oHTMLControl.Cont.TaxIE.Document.Selection.CreateRange()
THIS.oRange.Expand("textedit")
ELSE
IF ATC("__",THIS.oRange.Text,THIS.nForwardOccurance)=0
THIS.oRange = THIS.oHTMLControl.Cont.TaxIE.Document.Selection.CreateRange()
THIS.oRange.Expand("textedit")
ELSE
THIS.oRange.Collapse(.F.)
ENDIF
ENDIF

nPos = ATC("__",THIS.oRange.Text,THIS.nForwardOccurance)

IF nPos>0
THIS.oRange.Move("Character",nPos)
THIS.oRange.Expand("Word")

DO WHILE (" "$THIS.oRange.text) && to remove trailing spaces
THIS.oRange.moveEnd("character", -1)
ENDDO

THIS.oRange.Select()
THIS.oRange.ScrollIntoView()
THIS.nForwardOccurance = THIS.nForwardOccurance + LEN(THIS.oRange.Text)
ELSE
THIS.nForwardOccurance = 1
THIS.oRange.Move("Character",1)
THIS.oRange.Select()
ENDIF
ENDIF
ENDPROC


None of methods working and the cursor not moving by any of method.

PS: The code is working if Document Mode is IE8 or lower, and doesn't work if it's higher than IE8.

I have checked that the Move() and Select() doesn't work.

I hope I could explain the issue.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform