Setting focus on an input text element with IHTMLElement2::focus()

Setting focus on an input text element with IHTMLElement2::focus()

Post by Jan Osted » Fri, 05 Mar 2004 00:27:49


Hello everybody!
I have a MFC app with several views based on CHtmlView. In one of
them I have a form with several text input elements. If I try to set focus to
one of the input fields by means of IHTMLElement2::focus() it works fine
if the view in question doesn't already have focus, i.e. another view has
input focus. But if the page in the view itself has focus (not one of its
input fields) it doesn't work. The caret doesn't show up and keyboard input
isn't received by the element. Somehow focus seems to be on the element
though, because if I tab to the next element the caret shows up in the
adjacent input field. What I'm I doing wrong? I'm afraid I might be causing this
problem myself by somehow stealing the focus right after it is set, but while
I keep searching for that prospective bug I also want to ask if somebody
else in the group has encountered the same problem. Any help would be
greatly appreciated.
Regards
Jan

Environment: VC++ 6.0, MFC (SDI), IE6, Win98
 
 
 

Setting focus on an input text element with IHTMLElement2::focus()

Post by Jan Osted » Sun, 07 Mar 2004 01:16:53

Hi again!
I've found the problem, it was my own fault. IHTMLElement2::focus() works
fine as far as I can tell.
The fact that I didn't get any responses to my post made me understand that
the problem was not a common one but rather a bug in my code. So no
responses at all can also give useful information.
Regards
Jan