DGL https://delphigl.com/forum/ |
|
TWebBrowser steals focus from full-screen OpenGL Application https://delphigl.com/forum/viewtopic.php?f=19&t=8049 |
Seite 1 von 1 |
Autor: | dpm_dpmartin [ Sa Dez 20, 2008 19:53 ] |
Betreff des Beitrags: | TWebBrowser steals focus from full-screen OpenGL Application |
Can anyone provide any guidance to a problem I am having with a TWebBrowser I am using in a full-screen OpenGL application. It seems that the TWebBrowser steals focus after loading some pages and will not release it, i.e. I cannot return focus to the TForm so I can move around my user interface with keypresses or the MCE remote buttons (many of which are keypresses anyway). When I start up, I set the TWebBrowser's properties so that it is not intrusive (after all, it is not meant to be seen, it is just a way of getting at data held on the web in HTML format) - TabStop := False; Silent := True; Visible := False; MenuBar := False; StatusBar := False; AddressBar := True; Top := -10; Left := -10; Height := 0; Width := 692; - and this means you see nothing of the browser window itself. So, the TWebBrowser is on a full-screen TForm, which is where the OpenGL stuff is being rendered, the mouse pointer is disabled as I use the MCE Remote to control the user interface. I use the TWebBrowser.Navigate method to go to URLs, the HTML is then accessed via its DocumentComplete method and the OleObject.Document.documentElement.innerHTML property, the HTML is parsed for pertinent information and then saved - to a file for presenting to the user via OpenGL. After that, I often find that the TWebBrowser has stolen focus and my full-screen OpenGL application appears frozen, as the UI can't be controlled. I have tried using "frmMain.SetFocus;" and a variety of other methods, including simulating a left button mouse down and mouse up event on the form's handle. I have a timer executing every 3 seconds on the TForm and it consistently tells me that Screen.ActiveControl.ClassName; is TWebBrowser. I can't figure out how to either (preferably) stop TWebBrowser taking focus in the first place, or (second choice) come up with a sure fire way (beyond all the normal ActiveControl, SetFocus, SetForegroundWindow, SetActiveWindow methods) to ensure that I can give the TForm focus again and ensure TWebBrowser doesn't retain it. Oh, I also tried embedding it inside a TPanel (just as an experiment) and that failed too. Any ideas? |
Autor: | dpm_dpmartin [ Sa Dez 20, 2008 23:32 ] |
Betreff des Beitrags: | |
OK, Kinda solved this by creating the TWebBrowser at runtime and destroying it as soon as I have taken the HTML I need to parse from it. This means a lot of creating and destroying (every time I want to download Lyrics from the Internet, actually) but at least it doesn't hold the focus and stop the UI from working. There is a little flash I see on the screen as it is created which is the only side-effect, strange as I am creating it with Visible := False and Height := 0, but there you go, I suppose. Bit of a niggle with full-screen OpenGL and applications that want to make use of the TWebBrowser. If there's any other way around this I would still like to hear about it. |
Autor: | Lord Horazont [ So Dez 21, 2008 12:00 ] |
Betreff des Beitrags: | |
Why dont you use components like the Indy HTTP Sockets to get the HTML contents? This avoids the usage of the MS Internet explorer thing. greetings Lord Horazont |
Autor: | dpm_dpmartin [ Mo Dez 22, 2008 01:48 ] |
Betreff des Beitrags: | |
Yes, I like this - many thanks! It is seemingly much faster too... I just got caught out for a while because HandleRedirects needs to be False for my jumping-off point in www.google.co.uk and then needs to be True for the Lyrics sites themselves. The HTML returned also seems ever so slightly different, so I will have to change what I am scanning for in most instances, but I think this is a small price to pay for having something so slick. The only issue is, is that it is so fast at returning (and I believe it blocks a lot of the UI working too) that I don't have time to display my "Please Wait" rotating arrows, like an old hourglass. Again, a small price to pay. So - with a bit of work - I think I will have this working as I would like. |
Seite 1 von 1 | Alle Zeiten sind UTC + 1 Stunde |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |