weird page 2 - Dave's Blog

Search
My timeline on Mastodon

Notes on Creating Internet Explorer Extensions in C++ and COM

2009 Mar 20, 4:51

Working on Internet Explorer extensions in C++ & COM, I had to relearn or rediscover how to do several totally basic and important things. To save myself and possibly others trouble in the future, here's some pertinent links and tips.

First you must choose your IE extensibility point. Here's a very short list of the few I've used:

Once you've created your COM object that implements IObjectWithSite and whatever other interfaces your extensibility point requires as described in the above links you'll see your SetSite method get called by IE. You might want to know how to get the top level browser object from the IUnknown site object passed in via that method.

After that you may also want to listen for some events from the browser. To do this you'll need to:

  1. Implement the dispinterface that has the event you want. For instance DWebBrowserEvents2, or HTMLDocumentEvents, or HTMLWindowEvents2. You'll have to search around in that area of the documentation to find the event you're looking for.
  2. Register for events using AtlAdvise. The object you need to subscribe to depends on the events you want. For example, DWebBrowserEvents2 come from the webbrowser object, HTMLDocumentEvents come from the document object assuming its an HTML document (I obtained via get_Document method on the webbrowser), and HTMLWindowEvents2 come from the window object (which oddly I obtained via calling the get_script method on the document object). Note that depending on when your SetSite method is called the document may not exist yet. For my extension I signed up for browser events immediately and then listened for events like NavigateComplete before signing up for document and window events.
  3. Implement IDispatch. The Invoke method will get called with event notifications from the dispinterfaces you sign up for in AtlAdvise. Implementing Invoke manually is a slight pain as all the parameters come in as VARIANTs and are in reverse order. There's some ATL macros that may make this easier but I didn't bother.
  4. Call AtlUnadvise at some point -- at the latest when SetSite is called again and your site object changes.

If you want to check if an IHTMLElement is not visible on screen due how the page is scrolled, try comparing the Body or Document Element's client height and width, which appears to be the dimensions of the visible document area, to the element's bounding client rect which appears to be its position relative to the upper left corner of the visible document area. I've found this to be working for me so far, but I'm not positive that frames, iframes, zooming, editable document areas, etc won't mess this up.

Be sure to use pointers you get from the IWebBrowser/IHTMLDocument/etc. only on the thread on which you obtained the pointer or correctly marshal the pointers to other threads to avoid weird crashes and hangs.

Obtaining the HTML document of a subframe is slightly more complicated then you might hope. On the other hand this might be resolved by the new to IE8 method IHTMLFrameElement3::get_contentDocument

Check out Eric's IE blog post on IE extensibility which has some great links on this topic as well.

PermalinkCommentstechnical boring internet explorer com c++ ihtmlelement extension

The Weird And Wonderful Tech Art Of ITP's Winter Show

2008 Dec 29, 2:45Cool tech art projects from ITP.PermalinkCommentsart education itp nyc via:thefangmonster gizmodo photo gallery

G1 Android Phone

2008 Nov 9, 11:29

T-Mobile G1 Wallpapers by romainguy
I finally replaced my old regular cell-phone which was literally being held together by a rubber band with a fancy new G1, my first Internet accessible phone.

I had to call the T-Mobile support line to get data added to my plan and the person helping me was disconcertingly friendly. She asked about my weekend plans and so I felt compelled to ask her the same. Her plans involved replacing her video card so she could get back to World of Warcraft and do I enjoy computer gaming? I couldn't tell if she was genuine or if she was signing me up for magazines.

I was with Sarah in her new car, trying out the phone's GPS functionality via Google Maps while she drove. I switched to Street View and happened to find my car. It was a weird feeling, kind of like those Google conspiracy videos.

The phone runs Google's open source OS and I really enjoy the application API. Its all in Java and URIs and mime-types are sort of basics. Rather than invoking the builtin item picker control directly you invoke an 'intent' specifying the URI of your list of items, a mime-type describing the type of items in the list, and an action 'PICK' and whatever is registered as the picker on the system pops up and lets the user pick from that list. The same goes if you want to 'EDIT' an image, or 'VIEW' an mp3.

I wanted to replace the Google search box gadget that appears on the home screen with my own search box widget that uses OpenSearch descriptors but apparently in the current API you can't make home screen gadgets without changing parts of the OS. My other desired application is something to replace this GPS photo tracker device by recording my location to a file and an additional program on my computer to apply those locations to photos.

PermalinkCommentstmobile personal api phone technical g1 android google

PSFK - Trends, Ideas & Inspiration

2008 Oct 15, 2:53Stylish blog that looks like it has interesting cultural and business related articles and links (not just weird/humorous).PermalinkCommentsblog web advertising monthly design culture business

Fantasy Magazine - Guest Column: Five Thoughts On The Popularity Of Steampunk

2008 Sep 26, 2:22This made me laugh: "People think of goths as weirdoes who take vampires too seriously, and therefore they can't help being worried on some level that a crazy goth might, you know, want to make them bleed. Whereas steampunks are - what? Weirdoes who take pocket-watches too seriously? What are they gonna do, vehemently tell you what time it is?"PermalinkCommentssteampunk article goth scifi geek via:ethan_t_hein

Crispin Porter + Bogusky

2008 Jul 11, 1:39The ad agency that Microsoft has a new deal with has done all of the interesting or weird ad campaigns I can think of: crazy BK commercials, f'd up Sprite commercials, the KNOW HIV dancing people... Of course their site is Flash.PermalinkCommentsad advertising business

Language Log: Egg, penis, whatever

2008 Feb 18, 3:05A case study on the origins of a humorous mistranslation. FTA: "The really weird ones are apparently from dictionary look-up errors ... not just taking an unlikely choice from the correct entry, but actually reading a different (but nearby) entry."PermalinkCommentshumor language blog article translate mistranslation languagelog

Quantum mechanics and Tomb Raider - What's new

2008 Feb 8, 12:52FTA: "Quantum mechanics has a number of weird consequences... In trying to come up with a classical conceptual model in which to capture these non-classical phenomena, we eventually hit upon using the idea of using computer games as an analogy. ...let usPermalinkCommentshumor nerd science quantum-mechanics tomb-raider game gaming

Wikipedia Tools

2007 Sep 12, 6:54I'm visiting Wikipedia more and more recently but I always find myself reading the referenced webpages to get the full context of quotes and for more info. Basically I use Wikipedia as an introduction and a place to look for links. For times when I'm looking for opinions rather than facts I like to use Everything2. No need to check references there.

There's the much hyped WikiScanner tool which reports who has been making anonymous (thought to be anonymous at the time anyway) edits to Wikipedia. Its humorous and interesting in a few cases, but in general I think its stretching to say that because an IP address range is owned by a corporation and someone edited Wikipedia on an IP in that range that you can attribute that edit to that corporation. If I edited Wikipedia I'd probably do a bit of that during my lunch break, but that wouldn't mean that Microsoft wants the Wikipedia pages for Weird Al, Dave Risney, URIs, or whatever else I would edit on Wikipedia changed.

Also, via Everything Is Miscellaneous I found the tool Wiki Dashboard. Wiki Dashboard proxies Wikipedia and on each page shows a timeline view at the top with who made edits and when. Its nice to see a gentle curve down from an initial spike at the beginning for topics you don't imagine to be controversial. As the canonical test page for this service I looked up 'Elephant' the Wikipedia page Stephen Colbert suggested folks vandalize on his show on 2006 July 31st. If you look at the Wiki Dashboard Elephant page you can see a very large spike in edits on that date. That's all I need to see.

As a side note, for the link on Stephen Colbert suggesting folks vandalize Wikipedia I linked to a Wikipedia article. Is it inappropriate to provide info about Wikipedia being vandalized and thus incorrect via a link to a Wikipedia article?PermalinkCommentswikidashboard stephen-colbert wikality wikipedia wikiscanner colbert-report

Dark Roasted Blend: Creepy High Voltage Installations

2007 Jul 4, 11:21Photos of a giant high voltage installationPermalinkCommentsphotos steampunk architecture electricity history science technology weird

New XSLT - IE7 XML Source View Upgrade Part 2

2007 May 11, 8:55Last time, I had written some resource tools to allow me to view and modify Windows module resources in my ultimate and noble quest to implement the XML content-type fragment in IE7. Using the resource tools I found that MSXML3.DLL isn't signed and that I can replace the XSLT embedded resource with my own, which is great news and means I could continue in my endevour. In the following I discuss how I came up with this replacement for IE7's XML source view.

At first I thought I could just modify the existing XSLT but it turns out that it isn't exactly an XSLT, rather its an IE5 XSL. I tried using the XSL to XSLT converter linked to on MSDN, however the resulting document still requires manual modification. But I didn't want to muck about in their weird language and I figured I could write my own XSLT faster than I could figure out how theirs worked.

I began work on the new XSLT and found it relatively easy to produce. First I got indenting working with all the XML nodes represented appropriately and different CSS classes attached to them to make it easy to do syntax highlighting. Next I added in some javascript to allow for closing and opening of elements. At this point my XSLT had the same features as the original XSL.

Next was the XML mimetype fragment which uses XPointer, a framework around various different schemes for naming parts of an XML document. I focused on the XPointer scheme which is an extended version of XPath. So I named my first task as getting XPaths working. Thankfully javascript running in the HTML document produced by running my XSLT on an XML document has access to the original XML document object via the document.XMLDocument property. From this this I can execute XPaths, however there's no builtin way to map from the XML nodes selected by the XPath to the HTML elements that I produced to represent them. So I created a recursive javascript function and XSLT named-template that both produce the same unique strings based on an XML node's position in the document. For instance 'a3-e2-e' is the name produced for the 3rd attribute of the second element of the root element of the XML document. When producing the HTML for an XML node, I add an 'id' attribute to the HTML with the unique string of the XML node. Then in javascript when I execute an XPath I can discover the unique string of each node in the selected set and map each of them to their corresponding positions in the HTML.

With the hard part out of the way I changed the onload to get the fragment of the URI of the current document, interpret it as an XPath and highlight and navigate to the selected nodes. I also added an interactive floating bar from which you can enter your own XPaths and do the same. On a related note, I found that when accessing XML files via the file URI scheme the fragment is stripped off and not available to the javascript.

The next steps are of course to actually implement XPointer framework parsing as well as the limited number of schemes that the XPointer framework specifies.PermalinkCommentsxml xpointer msxml res xpath xslt resource ie7 technical browser ie xsl

OS-Tan - Gallery: Lamest Technology Mascots Ever (Wired)

2007 May 2, 1:00Apparently there's something called OS-tan in which Windows OSes are represented as anime styled characters. Very odd.PermalinkCommentsarticle os-tan humor images weird anime

Aquanaut adventure

2007 Apr 23, 1:07An Australian biologist lives in a "bio-regenerative microcosm" an enclosed box underwater for weeks. In that time he writes a song...PermalinkCommentsscience article weird biodome biosub

Aqua Teen Hunger Force Colon Movie Film for Theaters

2007 Apr 15, 7:37Friday Jon, Daniil, and I saw Aqua Teen Hunger Force Colon Movie Film for Theaters. It was really great. The quality of individual Aqua Teen episodes varies wildly but this movie was very funny. It was like watching an excellent episode that happened to be 87 minutes long.

I had some difficulty generating interest for the movie as many didn't think this was 'their kind of movie'. I asked Sarah and she said no but I talked to her about it again later after she watched a clip and she said she really didn't want to see it because it looked too weird. I asked her what she saw in the clip and she said a man with weird pants was talking with french fries while a drink was getting a meatball to push him around in a cart.

Well, when you put it like that it does sound weird...PermalinkCommentsmovie personal nontechnical

NAILS

2006 Nov 13, 12:34Crazy animated flash deals. Crazy.PermalinkCommentscool webdesign weird humor flash interactive art animation

Proceedings of the Athanasius Kircher Society

2006 Oct 30, 11:09PermalinkCommentsblog cool culture history humor weird

YouTube - Weird Al - White & Nerdy

2006 Oct 22, 3:54Music Video for Weird Al's song White and NerdyPermalinkCommentsmusic video music-video weird-al white-and-nerdy

Pierced Eyeglasses [The Publisher’s Ring]

2006 May 22, 3:46The idea of hanging eyeglasses from a piercing or a combination of piercings or even transdermal implants is something that a lot of us have toyed with — as I was writing this, my old boss Tom Brazda reminded me that almost ten years ago we made a set oPermalinkCommentscool culture hardware glasses piercing design weird bodymod
Older EntriesNewer Entries Creative Commons License Some rights reserved.