In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
WebBrowser SetFocus Question
WebBrowser SetFocus Question
Hello Xailers,
I'm having an issue trying to set the focus on the webbrowser after I enter the url to navigate.
It only sets the focus if I click with the mouse once on the component, after that when I type any url and click ENTER, it automaticaly sets the focus on the webbrowser.
Other question, when the focus is on the webbrowser, i cant trigger any event on the form, like the onKeyDown, is there any way to do that?
Thanks,
Juliano
I'm having an issue trying to set the focus on the webbrowser after I enter the url to navigate.
It only sets the focus if I click with the mouse once on the component, after that when I type any url and click ENTER, it automaticaly sets the focus on the webbrowser.
Other question, when the focus is on the webbrowser, i cant trigger any event on the form, like the onKeyDown, is there any way to do that?
Thanks,
Juliano
WebBrowser SetFocus Question
Juliano,
> I'm having an issue trying to set the focus on the
> webbrowser after I enter the url to navigate.
> It only sets the focus if I click with the mouse once on the
> component, after that when I type any url and click ENTER,
> it automaticaly sets the focus on the webbrowser.
How is you doing that? Please, I need a simple example to test it.
> Other question, when the focus is on the webbrowser, i cant
> trigger any event on the form, like the onKeyDown, is there
> any way to do that?
When the OCX has focus, it catches all keyboard strokes, and doesn't
redirect them to the form, as Xailer's native controls do. There is an
OnKeyDown event in the OCX subsystem, that works in almost OCX, but I'm
affraid that WebBrowser is not one of them. That is, OnKeyDown doesn't
work in WebBrowser, since it doesn't notifies its container.
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
> I'm having an issue trying to set the focus on the
> webbrowser after I enter the url to navigate.
> It only sets the focus if I click with the mouse once on the
> component, after that when I type any url and click ENTER,
> it automaticaly sets the focus on the webbrowser.
How is you doing that? Please, I need a simple example to test it.
> Other question, when the focus is on the webbrowser, i cant
> trigger any event on the form, like the onKeyDown, is there
> any way to do that?
When the OCX has focus, it catches all keyboard strokes, and doesn't
redirect them to the form, as Xailer's native controls do. There is an
OnKeyDown event in the OCX subsystem, that works in almost OCX, but I'm
affraid that WebBrowser is not one of them. That is, OnKeyDown doesn't
work in WebBrowser, since it doesn't notifies its container.
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
WebBrowser SetFocus Question
Hello Jose,
> How is you doing that? Please, I need a simple example to test it.
Here goes the example, I left some comments on the form, on how to make it work.
> When the OCX has focus, it catches all keyboard strokes, and doesn't
> redirect them to the form, as Xailer's native controls do. There is an
> OnKeyDown event in the OCX subsystem, that works in almost OCX, but I'm
> affraid that WebBrowser is not one of them. That is, OnKeyDown doesn't
> work in WebBrowser, since it doesn't notifies its container.
Thank you for answering me this question.
Thanks,
Juliano
Attached files WebBrowser.zip (7.8 KB)Â
> How is you doing that? Please, I need a simple example to test it.
Here goes the example, I left some comments on the form, on how to make it work.
> When the OCX has focus, it catches all keyboard strokes, and doesn't
> redirect them to the form, as Xailer's native controls do. There is an
> OnKeyDown event in the OCX subsystem, that works in almost OCX, but I'm
> affraid that WebBrowser is not one of them. That is, OnKeyDown doesn't
> work in WebBrowser, since it doesn't notifies its container.
Thank you for answering me this question.
Thanks,
Juliano
Attached files WebBrowser.zip (7.8 KB)Â
WebBrowser SetFocus Question
Juliano,
> Here goes the example, I left some comments on the form, on
> how to make it work.
Thanks for your sample.
>> When the OCX has focus, it catches all keyboard strokes,
>> and doesn't redirect them to the form, as Xailer's native controls
>> do. There is an OnKeyDown event in the OCX subsystem, that works in
>> almost OCX, but I'm affraid that WebBrowser is not one of them. That is,
>> OnKeyDown doesn't work in WebBrowser, since it doesn't notifies its
>> container.
>
> Thank you for answering me this question.
You're wellcome.
I've been working on this issue, and I belive it's now fixed. Moreover,
I've even got the OnKeydown event to work fine, although it's fired
asyncronously.
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
> Here goes the example, I left some comments on the form, on
> how to make it work.
Thanks for your sample.
>> When the OCX has focus, it catches all keyboard strokes,
>> and doesn't redirect them to the form, as Xailer's native controls
>> do. There is an OnKeyDown event in the OCX subsystem, that works in
>> almost OCX, but I'm affraid that WebBrowser is not one of them. That is,
>> OnKeyDown doesn't work in WebBrowser, since it doesn't notifies its
>> container.
>
> Thank you for answering me this question.
You're wellcome.
I've been working on this issue, and I belive it's now fixed. Moreover,
I've even got the OnKeydown event to work fine, although it's fired
asyncronously.
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
WebBrowser SetFocus Question
Juliano,
> I'm having an issue trying to set the focus on the
> webbrowser after I enter the url to navigate.
The problem is that when the webrowser OCX is created, it doesn't create
all of its components. It's only done when a web page has began to
download. So, in order to work what you want, it's needed to do a delay.
I.e (from your sample):
METHOD FormInitialize( oSender ) CLASS TForm1
LOCAL nTicks
WITH OBJECT ::oOcx := TWebBrowser():New( ::oBevel1 )
:nAlign := alCLIENT
:Create()
END
::oOcx:Navigate(::oEdit1:value)
// Causes a delay for about 1 second
nTicks := GetTickCount() + 1000
WHILE GetTickCount() < nTicks
ProcessMessages()
ENDDO
// After that, you can set the focus
::oOcx:SetFocus() // This SetFocus does not work, even if i put
it on the event navigationComplete from the webbrowser
RETURN Nil
> It only sets the focus if I click with the mouse once on the
> component, after that when I type any url and click ENTER,
> it automaticaly sets the focus on the webbrowser.
It's now fixed and working fine.
> Other question, when the focus is on the webbrowser, i cant
> trigger any event on the form, like the onKeyDown, is there
> any way to do that?
I've 'hacked' a bit the OCX support to deal with IWebBrowser keystrokes,
and it's working now. But the event is fired asynchronously. That means
that you may receive the OnKeydown event at any time after the key is
pressed in the OCX, while the OCX itself continues running, and any
returned value from the event is completely ignored.
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
> I'm having an issue trying to set the focus on the
> webbrowser after I enter the url to navigate.
The problem is that when the webrowser OCX is created, it doesn't create
all of its components. It's only done when a web page has began to
download. So, in order to work what you want, it's needed to do a delay.
I.e (from your sample):
METHOD FormInitialize( oSender ) CLASS TForm1
LOCAL nTicks
WITH OBJECT ::oOcx := TWebBrowser():New( ::oBevel1 )
:nAlign := alCLIENT
:Create()
END
::oOcx:Navigate(::oEdit1:value)
// Causes a delay for about 1 second
nTicks := GetTickCount() + 1000
WHILE GetTickCount() < nTicks
ProcessMessages()
ENDDO
// After that, you can set the focus
::oOcx:SetFocus() // This SetFocus does not work, even if i put
it on the event navigationComplete from the webbrowser
RETURN Nil
> It only sets the focus if I click with the mouse once on the
> component, after that when I type any url and click ENTER,
> it automaticaly sets the focus on the webbrowser.
It's now fixed and working fine.
> Other question, when the focus is on the webbrowser, i cant
> trigger any event on the form, like the onKeyDown, is there
> any way to do that?
I've 'hacked' a bit the OCX support to deal with IWebBrowser keystrokes,
and it's working now. But the event is fired asynchronously. That means
that you may receive the OnKeydown event at any time after the key is
pressed in the OCX, while the OCX itself continues running, and any
returned value from the event is completely ignored.
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
WebBrowser SetFocus Question
Jose, Juliano,
this is not needed:
> nTicks := GetTickCount() + 1000
> WHILE GetTickCount() < nTicks
> ProcessMessages()
> ENDDO
WHILE ::oOCX:Busy()
ProcessMessages()
END
Regards,
José Lalín
this is not needed:
> nTicks := GetTickCount() + 1000
> WHILE GetTickCount() < nTicks
> ProcessMessages()
> ENDDO
WHILE ::oOCX:Busy()
ProcessMessages()
END
Regards,
José Lalín
WebBrowser SetFocus Question
José,
> this is not needed:
>
>> nTicks := GetTickCount() + 1000
>> WHILE GetTickCount() < nTicks
>> ProcessMessages()
>> ENDDO
>
> WHILE ::oOCX:Busy()
> ProcessMessages()
> END
Yes, you are right. I was focused in the TOcx source and didn't remember
that method from TWebBrowser
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
> this is not needed:
>
>> nTicks := GetTickCount() + 1000
>> WHILE GetTickCount() < nTicks
>> ProcessMessages()
>> ENDDO
>
> WHILE ::oOCX:Busy()
> ProcessMessages()
> END
Yes, you are right. I was focused in the TOcx source and didn't remember
that method from TWebBrowser
Regards,
Jose F. Gimenez
http://www.xailer.com
http://www.xailer.info
WebBrowser SetFocus Question
I have tested it and now its working very well.
Thanks for all your help,
Juliano
Thanks for all your help,
Juliano