Blog Home  Home RSS 2.0 Atom 1.0 CDF  
Hairy Spider Blog - Monday, February 27, 2006
A web of intrigue
 
 Tuesday, February 28, 2006
Well it's not all that difficult.

I've just created something that will enable one to view and edit any scripts that are loaded in the browser.



In essence all you need to do is to create a class library and include a reference to the DOMHelper dll. Then you just need to create a usercontrol. Design the control as usual and when you come to work on the code element make the class inherit the bho.csseditor.Plugin class.


The first method you'll want to override is the Activate method this will be called when a new document is loaded and when the tab is made visible. The title property will be what's displayed in the tab and there's a property on the base object called ParentFrame from which you can get a reference to the mshtml.WebBrowser and mshtml.Document objects.

Once you are happy about life and your coding, then you can import your shiny new plugin into the DOMHelper. To do this is actually a bit of a nightmare, much harder than I thought it would be, but I'll let you know how I managed it and you can do the same back to me:

I found out using FUSLOGVW that you may need to add the DOMHelper and interop.shdocvw assemblies to the GAC. Having thought about this again you may also be able to get away with placing your assembly in the same folder as the DOMHelper that is loaded by Internet Explorer. You'll have to try this yourself.

Anyway, once you've added the assemblies to the GAC using GACUtil (available as part of the 300Mb SDK) you can then load the assembly. Click the little monitor image and choose add-ins and follow the instructions from there.

There you go - you're up and away.

As a starter for 10 you can download the DOMScripter Visual Studio Project, which also contains a binary if you're too lazy to build the code yourself.

Any comments would be welcome.

Notes:
  • You won't be able to do anything in the designer when the the class inherits the Plugin class because it's an abstract class, ya de yada.
  • If you have a textbox on your own plugin then you may want to ensure that it receives the attention that it's due i.e. handles backspace correctly by handling the GotFocus() event and calling the ParentFrame.SetFocus().
  • You can use the CLR Debugger (also part of the SDK) to run IE and find any bugs.

Usual disclaimers apply.
2/28/2006 5:01:01 PM (GMT Standard Time, UTC+00:00)  #      .net | c-sharp | DOM Helper | Inline CSS Editor  | 
 Monday, February 27, 2006
I was asked if there was a simple way to write a browser helper object (BHO) using C#.

It's actually very easy to do this if you know what you're looking for, I used the information on steven cohn's weblog everything is there that you need to write a BHO. I recommend that you read the article - it's very concise and accurate. You can download my interpretation of this BHO article in a single file. When you download this file and include it in a project you'll need to add the Shdocvw COM object and in .Net version 2 there's a .net component called Microsoft.mshtml.

It's incredibly easy to write something that will do the very simple, however when you get into messing with the mshtml and shdocvw then you may run into problems. I had terrible trouble with the DOM Helper. There's absolutely no documentation for mshtml. So most of it is trial, error and a fair bit of guesswork.

If you're looking for something quick then I would recommend that you have a stab at implementing a menu extension. They are far easier to write and can be called from the context menu of IE.


2/27/2006 6:02:57 PM (GMT Standard Time, UTC+00:00)  #      .net | c-sharp  | 
 Friday, February 24, 2006
Well I've finally got round to producing the inline CSS editor that I wanted to do in the first place. The first stab, was in C++ and although it worked, it was a complete nightmare. It didn't allow you to alter CSS files that were loaded as "@import". This new version does, it parses the CSS and adds each individual rule back to the style sheet. Simply replacing the CSSText caused a memory corruption error in MSHTML.

It's been re-written it in C# using Pavel Zolnikov's BandObjects. I've also added a few extras such as a DOM Explorer and the ability to add plugins to the band object.

While it's been writting in C# 2.0 there's not much use of the new version 2 features. Mind I was most satisfied with my first foray into using generics. I didn't think that there'd be much use for them but I did find a use, albeit slightly contrived.

So you want to see the screen shot?



OK, so now you like the look of it, you want to know how to get it and play with it?

I really wanted to deploy this as with the proper installer however, C# Express doesn't include that so you going to have to install the file manually:

First of all download DOM Helper.

Extract the files in that archive to a location on your harddrive that you can remember (e.g. c:\DOMHelper\).

Next you'll need to regasm the assembly open a cmd shell ( Start -> Run -> cmd) and type:

"%windir%/Microsoft.Net/Framework/v2.0.50727/regasm" /codebase c:\DOMHelper\DOMHelper.dll

This should have registered the assembly, and the next time you open Internet Explorer you will be able to view DOM Helper by choosing it from View -> Explorer Bars -> DOM Helper.

If for any reason you don't like it to uninstall run the following command

"%windir%/Microsoft.Net/Framework/v2.0.50727/regasm" /u c:\DOMHelper\DOMHelper.dll


Thanks to www.famfamfam.com/lab/icons/silk/ for the icons

If you want to know more, then please let me know.

2/24/2006 2:32:05 PM (GMT Standard Time, UTC+00:00)  #      c-sharp | DOM Helper | Downloads | Inline CSS Editor  | 
 Tuesday, February 21, 2006
Following on from a previous entry on powerpoint presentations: http://www.hairy-spider.com/2004/10/29/ExtractingAFlashFileFromAPowerpointPresentation.aspx

I've compiled the source included in that entry and uploaded it to the website for general consumption. I've done nothing to the code other than compile it.

When you download the file, you must extract the file somewhere on your machine. Please put it in a memorable and easy location, e.g. c:\

Then you need to open a command window ( start -> run... -> cmd) then you need to type something like:

c:\extractaflash.exe path_to_my_scrap_file.scrap c:\outfile.swf

This will then create a new file in the c:\ location called outfile.swf which will be the shockwave flash object.

I would work on a gui application but I don't have any sample scrap files to hand. So you'll have to make do with this.

You can now download the extractaflash executable.

As a side note, it's amazing how something you do can end up all over the shop in all sorts of code that you as the original writer of the code have no knowledge about. I don't really mind people using my code but a little bit of appreciation would be nice. I know that licenses are supposed to stop this sort of thing, but it's just a rude not even including a reference to the originator of the code.

2/21/2006 1:29:18 PM (GMT Standard Time, UTC+00:00)  #      c-sharp  | 
 Friday, February 17, 2006
2/17/2006 12:32:45 PM (GMT Standard Time, UTC+00:00)  #      Misc  | 
 Thursday, February 16, 2006
Recently a few of the items in my start menu have stopped working. Everytime I try to open the Run box I get a error message saying that windows cannot create a shortcut. I can get around this by doing Windows-Key + R. Help and support has the same error.

However, if I leave it too long, the whole of the start menu stops working then it's time to kill the explorer process and reload it. I tried rolling back to a previous state, and this seemed to have fixed it for a while. But it has started happening again.

I've read somewhere that regsrvr shell32.dll will work, but I've tried it with no success.

I haven't found any fix to this issue, and neither does anyone else. I'm investigating but we'll have to see if I'm going to have to rebuild my OS. If I do - I'll be really annoyed.

2/16/2006 9:16:12 PM (GMT Standard Time, UTC+00:00)  #      Misc  | 
 Wednesday, February 15, 2006
2/15/2006 3:46:26 PM (GMT Standard Time, UTC+00:00)  #      gmail | google  | 
 Tuesday, February 07, 2006
I think that Google have found a USP for their messenger application: you can archive your "chats" online.

It seems to have been the case with a lot of google products lately big promise, small delivery. Certainly Google Talk has suffered from few features which should be standard. Now it seems that there is a reason to use it, and that is that every chat you have using Google Talk can be archived in your gmail account and presumable included in any searches. This is a big leap forward, it's been ages since there has been any visible movement for Google Talk. I wonder how long it will be before those wacky Google developers allow you to send emoticons, or possibly in google speak "Gemicons."

I'd be interested to see what the online version is like. This is a departure from the usual, no big 2 year beta, now it's just a big announcement of a beta at some point. Maybe after the video and analytic debarcles, Google are being a little less risky. I hope not.





2/7/2006 10:36:52 AM (GMT Standard Time, UTC+00:00)  #      gmail | google  | 
Copyright © 2008 Rhys Jeremiah. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: