OpenNetCF sendkey to OpenNetCF webbrowser

R

rpatel4

This is on the smartphone, CF 1.1...
I'm embedding a OpenNetCF WebBrowser object into my form to display web
content.
I was giving the WebBrowser object focus, so that I can sroll up/down
the webpage, click on links, etc. One of the problems was that
clicking the back button minimized the form, as well as a few other
keys that my app uses weren't working since the browser had focus.

So instead, I thought I would let the form keep the focus, and pass on
the up/down/enter keys to the web-browser. But it doesn't appear to be
working properly...The web browser doesn't appear to be responding to
the key presses.

public void forwardKey(System.Windows.Forms.Control currentlyFocused,
string keys)
{
//give focus to web browser (objWebBrow has type
//OpenNETCF.Windows.Forms.WebBrowser
objWebBrow.Focus();

//send the key to the currently focused window
OpenNETCF.Windows.Forms.SendKeys.Send(keys);

//added a 1 second sleep just incase it wasn't synchronous
System.Threading.Thread.Sleep(1000);

//give focus back to form
currentlyFocused.Focus();

//trying to get browser to refresh
objWebBrow.Invalidate();
currentlyFocused.Invalidate();
currentlyFocused.Refresh();
}


Now If I comment out the currentlyFocused.Focus() line, then the
web-browser handles all future key presses, so the objWebBrow.Focus()
line seems to be workign okay

Also if I comment out the currentlyFocused.Focus() line, and press the
down key just once, the web-page does scroll down a bit --
so either the SendKeys.Send is correctly working,
or me pressing the down key somehow results in two keypresses (one I
capture and one the webbrowser captures after it gets focus),
or I'm getting focus back before Windows sends the key to the currently
active window (unlikely with a 1 second delay?).


In any case, does anyone have any suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top