Click here to Skip to main content
Click here to Skip to main content

FlashSelector - Block Flash selectively

, 5 Mar 2006 CPOL
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

Comments and Discussions

General(very late) Bugs & suggestion! Pinmembersteack9-Dec-09 9:08 
Questiondoes it work with Opera browser? or any browser?or messnger? Pinmembermaroq16-May-07 2:23 
AnswerRe: does it work with Opera browser? or any browser?or messnger? PinmemberJaeWook Choi7-Jun-07 8:21 
Questionnot compatible with IE7? PinmemberFittichklopfer12-Mar-07 23:47 
AnswerRe: not compatible with IE7? - correction PinmemberFittichklopfer13-Mar-07 7:05 
AnswerRe: not compatible with IE7? Pinmemberadamminorgeek6-Jun-07 12:32 
GeneralRe: not compatible with IE7? PinmemberJaeWook Choi7-Jun-07 8:14 
GeneralRe: not compatible with IE7? Pinmemberadamminorgeek7-Jun-07 15:20 
QuestionExcuse me,how to get the flash's url under mouse in webbrowser ctrl based application? Pinmember31415926533-Nov-06 2:22 
QuestionInterested in Freelance Work? PinmemberAjay Chadha7-Mar-06 19:34 
AnswerRe: Interested in Freelance Work? PinmemberJaeWook Choi8-Mar-06 12:15 
GeneralThe tabbed toolbar Pinmemberjhjhjhjhjhjh7-Mar-06 0:48 
GeneralRe: The tabbed toolbar PinmemberJaeWook Choi8-Mar-06 12:12 
JokeRe: The tabbed toolbar Pinmemberflyingxu8-Mar-06 21:14 
GeneralRe: The tabbed toolbar PinmemberDean Hallman21-Apr-06 7:04 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150224.1 | Last Updated 5 Mar 2006
Article Copyright 2006 by JaeWook Choi
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid