Click here to Skip to main content
13,594,172 members
Click here to Skip to main content
Add your own
alternative version


36 bookmarked
Posted 5 Mar 2006
Licenced CPOL

FlashSelector - Block Flash selectively

, 5 Mar 2006
Rate this:
Please Sign up or sign in to vote.
Flash block add-in using Internet Explorer BHO.

Sample Image - FlashSelector.png


When an Ad Flash is flying over the browser and blocking the contents that you wish to read, it is really annoying. There had been quite a lot of different approaches to block Flash but we were not able to utilize those existing Flash blocker's functionality, well, since after many web sites started using Flash as their menu system, a tool for multimedia and so on. We can not blindly block them all. It become a "Catch-22".

Selectively Toggling Block/Unblock Flash

I am not a Flash expert, but there are two kinds of Flash, windowed Flash and windowless Flash. Windowed Flash is known to be faster than the latter while windowless Flash can have the transparency feature. The new Flash blocking method that I will show here will only apply for windowed Flash, but windowless Flash will be addressed later.

My approach is simply using the CBT hook and the window message subclassing feature. When BHO is being loaded into the IE site through IObjectWithSite::SetSite, a CBT 'thread specific' hook is installed to monitor new window creation events, especially whose window class name is 'MacromediaFlashPlayerActiveX'. When a Flash window is found to be being created in the CBT hook procedure, a Flash window is subclassed again with a new message procedure ("FilterFlash.h"). In the new subclassed procedure's WM_PAINT message handler, the '[Blocked Flash]' message in the white background will be displayed instead of the actual Flash contents. But if the user clicks on a specific Flash window, the clicked Flash's original window message procedure will be restored to display the Flash contents. Simple!

Note how I handled WM_NCCREATE in "FiltherFlash.h". It is important to call Flash's original message procedure then subclass the Flash window 'again' since after calling Flash's original message procedure, our subclassing is getting reset somehow. Other than this, it's just simple windows subclassing and standard CBT hook procedure that everyone are already accustomed to.

Windowless Flash

Windowless Flash is mostly advertisement. Since they don't have a window, it is not possible to apply the above method to windowless Flash. So, I just copied the Flash blocking routine from John Osborn's Popup Blocker to hide Flash and animated GIFs. It is not a perfect method as windowless Flash can still be seen for a short time before the HTML page is completed loading, but it does work decently. As 'most' windowless Flash are ads, it seems reasonable to remove windowless Flash always. But, in case you want a certain Flash to be seen, I provided a temporary Flash blocking suspension key (customizable and one of ALT, CTRL, or SHIFT key).

Final Word

I wrote this add-in for myself a year ago, and I've been used this for the whole last year without any problem. This add-in has proven to be very useful for me, and my little hope is that someone can port this to third party browsers so that I can use this feature while I am using them.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

JaeWook Choi
Canada Canada
No Biography provided

You may also be interested in...

Comments and Discussions

General(very late) Bugs & suggestion! Pin
steack9-Dec-09 8:08
membersteack9-Dec-09 8:08 
Questiondoes it work with Opera browser? or any browser?or messnger? Pin
maroq16-May-07 1:23
membermaroq16-May-07 1:23 
AnswerRe: does it work with Opera browser? or any browser?or messnger? Pin
JaeWook Choi7-Jun-07 7:21
memberJaeWook Choi7-Jun-07 7:21 
Questionnot compatible with IE7? Pin
Fittichklopfer12-Mar-07 22:47
memberFittichklopfer12-Mar-07 22:47 
AnswerRe: not compatible with IE7? - correction Pin
Fittichklopfer13-Mar-07 6:05
memberFittichklopfer13-Mar-07 6:05 
AnswerRe: not compatible with IE7? Pin
adamminorgeek6-Jun-07 11:32
memberadamminorgeek6-Jun-07 11:32 
GeneralRe: not compatible with IE7? Pin
JaeWook Choi7-Jun-07 7:14
memberJaeWook Choi7-Jun-07 7:14 
GeneralRe: not compatible with IE7? Pin
adamminorgeek7-Jun-07 14:20
memberadamminorgeek7-Jun-07 14:20 
QuestionExcuse me,how to get the flash's url under mouse in webbrowser ctrl based application? Pin
31415926533-Nov-06 1:22
member31415926533-Nov-06 1:22 
QuestionInterested in Freelance Work? Pin
Ajay Chadha7-Mar-06 18:34
memberAjay Chadha7-Mar-06 18:34 
AnswerRe: Interested in Freelance Work? Pin
JaeWook Choi8-Mar-06 11:15
memberJaeWook Choi8-Mar-06 11:15 
GeneralThe tabbed toolbar Pin
jhjhjhjhjhjh6-Mar-06 23:48
memberjhjhjhjhjhjh6-Mar-06 23:48 
GeneralRe: The tabbed toolbar Pin
JaeWook Choi8-Mar-06 11:12
memberJaeWook Choi8-Mar-06 11:12 
JokeRe: The tabbed toolbar Pin
flyingxu8-Mar-06 20:14
memberflyingxu8-Mar-06 20:14 
GeneralRe: The tabbed toolbar Pin
Dean Hallman21-Apr-06 6:04
memberDean Hallman21-Apr-06 6:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02-2016 | 2.8.180618.1 | Last Updated 5 Mar 2006
Article Copyright 2006 by JaeWook Choi
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid