c# - How to detect when a winforms application creates a new window? -


i'm using webbrowser control in form application , want block popup/alert/prompt window can create.

currently, implementing various methods block popups like:

  • canceling various events fire when new window created.
  • changing global ie settings through registry make show less alerts , prompts.
  • using browser feature controls block popups.
  • injecting javascript every page disable functions can create new windows.
  • extending web browser control new events implementing things idochostshowui allow me block popups.
  • using "hidden" events of base activex webbrowser object newwindow2 , newwindow3.

all of combined blocks 99% of windows webbrowser control can create (the 1% being extremely rare cases javascript prompt() function called within iframe document located on different domain parent window, still haven't found way block :d).

but it's lot of code, making big mess can sometime interfere normal browsing. want know if there different approach. since of windows created webbrowser control created application's process, there way detect when application creates kind of window not main form , close instantly or block it's creation entirely?

update:

i have tried overriding wndproc method webbrowser control, no messages sent when prompt appears.

when overriding entire form, messages when prompt appears, related losing focus , not actual creation of prompt. able detect when prompt created, still not able block it's creation.

if want close window except current one, can use code below inside timer_tick event:

private void timer1_tick(object sender, eventargs e) {     (int = 0; < application.openforms.count; i++)     {         form form = application.openforms[i];         if (form != this)         {             form.close();             i--;         }     } } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -