Jump to content

caret position and id

- - - - -

  • Please log in to reply
1 reply to this topic

#1
davidbrook

davidbrook

    Newbie

  • Members
  • PipPip
  • 13 posts
I am trying to determine the id of an html inputtextfield on webbrowser by the position of the caret. so when the caret is blinking in it. I want to know what that id of that field is.

I am having trouble with this. I know i can do this by getcursorposition. but when i use getcaretposition it does not work.

i found out they give me two completely different coordinates.... can someone help me out with this? seems so simple, what am i doing wrong?

#2
Zorfox

Zorfox

    Learning Programmer

  • Members
  • PipPipPip
  • 36 posts
I wouldn’t use caret positioning. This does not necessarily imply the active element in a form! Instead use activelement. Below is an example of how it may be done using functions you have already. BTW, I would recommend setting an IHTMLInputElement variable to pass the SetFieldAttrib function.


var

  document: IHTMLDocument2;

  theForm: IHTMLFormElement;

  Field: String;

begin

  (*Check if the active element is an input field *)

  Field := (Webbrowser.Document as IHTMLDocument2).activeElement.tagName;

  if Field = 'INPUT' then

    begin

      (*Get the form number from your function*)

      theForm := GetFormByNumber(WebBrowser.Document as IHTMLDocument2,0);

      (*Color the field with your SetfieldAttrib function, get the input field name to pass to the function*)

      SetFieldAttrib(theForm,'an IHTMLInput variable','#FFFFFF')

    end;

end;





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users