May 2004 Entries

I'm sure most of you have seen this, but for those that haven't, I thought I'd repost it.  This is by far the coolest stick figure flash animation ever.  I've watched it so many times and it just never gets old.  Wish I knew how many hours it took this guy to make it.  It is purely genius. In a nutshell, it's just an animation of a little stick figure guy going ninja crazy on a bunch of other stick figures.  The ending is something to behold!

http://www.methodus2000.com/violence/fight.swf

 

Why oh why does it not work?  I've said that so many times, but for the life of me cannot figure this one out.

I thought I'd just go and play a little with Region objects for controls.  I basically use 3 images with a defined transparency color and generate Region objects from them.  I thought it would be a simple matter of being able to set the Region on my custom control depending on the state of the mouse (MouseEnter, MouseLeave, etc...).

So, if the mouse enters the control, I do a good old

this.Region = mouseOverRegion;

That works.  MouseLeave occurs so I do:

this.Region = mouseUpRegion;

That works.  Mouse enters again, so the same code earlier is run:

this.Region = mouseOverRegion;

InvalidArgumentException with the call stack being:

System.ArgumentException: Invalid parameter used.
   at System.Drawing.Region.GetHrgn(Graphics g)
   at System.Windows.Forms.Control.GetHRgn(Region region)
   at System.Windows.Forms.Control.set_Region(Region value)
   at Schmidt6.SKButton.SKButton_MouseEnter(Object sender, EventArgs e)

What?  Anyone have any clues on this?  I've tried just about everything in the book (except for the one that works naturally) including disposing the current this.Region, setting it to null, calling this.Region.MakeEmpty() and probably a few other things.  Nothing seems to get it to work.

Any help/insights appreciated.  So much for just “playing around” since I can't quit now until I get it solved.

Charlie...is...da...man!

Now I just need to convince him to post a RSS feed link so I can gobble his feed with my NewsGator.

P.S. This guy has some strange dreams which makes me think he watches wayyyy to much sci-fi stuff.

I have yet to post code on my blog, so now is the time.

I have various function nuggets that have followed me around like a lost sick puppy over the years and this is one of my most recent.  Since I work with a UI architecture that is very dynamic in nature and extremely plugin-oriented, I need to have a set of functions to explore the type information of objects and allow me to dynamically call methods and properties. Here is an example of such a function.  Let's say you had some XML that looked something like:


<Object type='Object.ProgID' prop1='XYZ' prop2='true' prop3='43' prop4='3.14159'/>

This is just an example but just by looking you can see that it defines a COM object (with the progID in the type attribute) with several different properties of varying data types (string, boolean, integer, float).  The first thing you need to do is obviously parse the relavent data out.  For instance, the parser finds a new Object tag, grabs the type attribute and does a CoCreateInstance to create the COM object (I'll leave that as an exercise for the reader...unless someone really doesn't know how to do it).  The parser then enumerates through each attribute grabbing 2 strings, the attribute name and the attribute value.  The parser doesn't need to worry about doing any type coercion (the method that follows does it for you).

So, at this point a COM object has been created and the parser is enumerating each attribute which corresponds to an actual property name in the COM object.  Here's the method that given a instance of a COM object, the property name (string) and the property value (string), calls the correct property setter on the object (criticism is expected but keep in mind the code is still rough since I'm still in implementation phase of the UI engine):

HRESULT CSomeClass::SetObjectProperty( IDispatch* pObject, BSTR propertyName, BSTR propertyValue )
{
    USES_CONVERSION;
    HRESULT hr = S_OK;
    DISPID dispID = 0;
    TYPEATTR* typeAttr;

    UINT puArgError;
   
   
// get ITypeInfo from object
    ITypeInfo* pTypeInfo;
    hr = pObject->GetTypeInfo( 0, 0, &pTypeInfo );

   
if
( FAILED(hr) )
    {
        LogMsg( 1, (1, "ERROR:Unable to get type info for pipeline object. Ensure that COM_MAP contains: COM_INTERFACE_ENTRY2( IDispatch, IMainInterfaceName )"));
       
return
FALSE;
    }

   
// get type attributes (# functions e.g.)
    pTypeInfo->GetTypeAttr(&typeAttr);

   
for
( WORD iFunction = 0; iFunction < typeAttr->cFuncs; iFunction++ )
    {
        FUNCDESC* funcDesc;
        CComBSTR methodName;   
        CComVariant vPropValue;

       
// get function description info
        hr = pTypeInfo->GetFuncDesc( iFunction, &funcDesc );

       
// make sure its a propput function
        if
( funcDesc->invkind != INVOKE_PROPERTYPUT && funcDesc->invkind != INVOKE_PROPERTYPUTREF )
        {
            pTypeInfo->ReleaseFuncDesc( funcDesc );
           
continue
;
        }

       
// get method name
        hr = pTypeInfo->GetDocumentation(funcDesc->memid, &methodName, 0, 0, 0);
       
if
( FAILED(hr) )
        {
            pTypeInfo->ReleaseFuncDesc( funcDesc );
           
continue
;
        }

       
// check to make sure we have the right property
        if
( CString(methodName).CompareNoCase(CString(propertyName )) != 0 )
        {
           
continue
;
        }
       
       
// the dispid
        dispID = funcDesc->memid;

       
// at this point we found the correct property function to call
       
// now we need to build the VARIANT arg
        vPropValue = propertyValue;
       
        vPropValue.ChangeType( funcDesc->lprgelemdescParam[0].tdesc.vt );

       
// build dispparams
       
// NOTE: PRB: Error 0x80020004 When Setting a Property (http://support.microsoft.com/support/kb/articles/q175/6/18.asp)
        DISPPARAMS dispParams;
        DISPID dispidNamed = DISPID_PROPERTYPUT;
        dispParams.rgvarg = NULL;

        dispParams.rgdispidNamedArgs = &dispidNamed;
        dispParams.rgvarg = &vPropValue;

        dispParams.cArgs = 1;
        dispParams.cNamedArgs = 1;

       
// invoke function (which is the propput method)
        HRESULT hr = pTypeInfo->Invoke( pObject, dispID, funcDesc->invkind, &dispParams, NULL, NULL, &puArgError );

       
if
( FAILED(hr) )
        {
           
// error setting property
            LogMsg( 1, (1, "Cannot set property \"%s\". hr=0x%x", OLE2T(methodName), hr ));
            pTypeInfo->ReleaseFuncDesc(funcDesc);
        }
       
else
        {
            pTypeInfo->ReleaseFuncDesc(funcDesc);
        }
    }

    pTypeInfo->Release();

   
return
TRUE;
}

I commented the different sections of the method so it should all be pretty clear.  I have several variations that exist but essentially do the same thing. For instance, one variation uses a hashtable of property name -> property values so I don't have to repeatedly call this method over and over again for each property.

There you have it.  My first code contribution.  I actually have another method that is way cooler than this one.  It basically accepts a COM object and a list of property name/property value pairs and calls a method.  Those name/value pairs are the parameters to the COM object's method.  The cool thing is that the list of pairs can be a) all strings and the method will change the types correctly and b) in any order (i.e. the name/value pairs do not have to match the order of the parameter list for the method. The dynamic method call method will order them and convert types for you).

Thoughts?

<ObiWan target='Windows' function='FolderDeletion'>
        <jedimindtrick>Move along! Move along!</jedimindtrick>
</ObiWan>

Ok, I'm sure everyone has this rant.  I've had it for a long time and here's hoping that one day it'll get changed (Longhorn maybe).  I go to my %TEMP% directory, hit CTRL-A to select all and do a SHIFT-DELETE to permantently delete all the files.  But lo' and behold it stop after 10 files saying one of them is in use and then stops.  Why can't they make it so it just skips the file and continues deleting the rest?  Is there some unknown architectural design flaw that will allow them to never implement something like that?  Or is their some reason it hasn't been changed all this time?  Oh well, time to do the CTRL-Click game in my %TEMP% folder now.

I am the lead architect for a component (specifically the presentation layer) on our team.  I have 1 other person helping me with implementation.  One day we had to add a new feature.  I designed a solution and handed it off to him and he came back and asked “why do we need it to do this? It wasn't in the requirements?”  I responded by saying something along the lines of “because eventually someone will ask for it”.  In fact, I find myself saying that over and over again.

Now here's a little background on what I'm doing.  I call my component an engine for good reason but will not delve into those reasons right now.  The best comparison you can make to a technology out there that is similar to what I'm doing is the engine that renders XAML or Mozilla using XUL.  I have had 3 main tenants from beginning until present day.  The engine must be 1) extensible, 2) customizable and 3) simple.  So, what if I followed his advice and just designed a new feature to work with that one single requirement.  Is it extensible? No.  Is it customizable? Probably not. Is it simple? Yes.  But you see, I have a definite “yes” for the 1st tenant so I immediately scrapped that design in favor of a design that supported all three.  However, I think he still tends to disagree.  To put it in example form, let's say you had a requirement to add a new feature that would transform the UI definition document from 1 form to another using XSLT.  Using his methodology, we go by the book.  We add a feature that takes the UI definition document, a path or stream to some XSLT and transform to some result document.  My methodology however is more along the lines of we take the UI definition document, a path or stream to some unknown format that a plugin only knows about, tell the plugin to transform to a result document.  We can then create an XSLT plugin, a javascript based plugin that uses a javascript source file (just thinking off the top of my head), and later on down the road we add a plugin for technology X that someone is creating in their garage right now.

So with the design just outlined, let's ask the questions again: 1) extensible? Yes via plugins. 2) customizable? yes, we can now mix and match different plugins based on what we want the engine to do 3) simple? Yup.

Now I must also say that their are some times where you just have to follow the requirment word for word.  For this project however, I am creating a framework/infrastructure type component and therefore need to anticipate features that developers may require in the future.

Thoughts?

A web site popped into my head today for some reason.  It's a website I haven't visited in a long time but it looks like it's still going strong.  deviantArt is a digital art community that really showcases a lot of creative talents on the net.  Back in my day, I actually submitted 3 items to the site.  For those interested, here they are:

Dermagine: This is a 3d rendering of a pill bottle with a label that says Dermagine on it.  Dermagine was a user interface engine that I created that supported such things as XML based UI definitions, runtime scripting, and the showcase feature “skinning”.  One of my magazine articles sort of detailed the constuction of the engine.  However, the article was supposed to be the first in the series outlining all features of a UI engine but due to complications was never finished.  Anyway, Dermagine, which was a research project, was picked up by my team here at HP and is now in a shipping product.  My current work is a continuation from Dermagine but is much more advanced (think XAML with the ability to switch from native GUI look and feel to HTML based UI's on the fly).  The code name for my current engine is Luka.

Plastic: This is a poem I did on a whim.  It should be pretty obvious what I'm talking about.  I took care not to add fluff lines.  Each line has significance.  Not my favorite, but it works.

Object Lesson: This poem is based off a short story I did back in high school.  The short story just rocked in my opinion.  I received a lot of positive feedback from it, but I eventually lost it.  This poem tried to bring back the essence of the story but it's just not as good.  I wanted to hook the reader in at the beginning and try and elevate the suspense while reading only to shock them at the end once they realize what is actually going on with this little boy.  The last few lines give you a hint (don't read ahead) as to what was actually going on.  Again, I wish I still had that story...it was pretty hilarious.

As far as the rest of deviantArt, there is some pretty amazing stuff.  I'm going to try and find some of my old favorites but I honestly don't remember what they were called.  The ones I remember are (all digital art pieces):

  • Futuristic Nazi soldier (no I'm not a Nazi but that piece was just so awesome looking)
  • Monk in a jungle.  The colors in it were just something to behold
  • A lost city in a jungle (made by the same author as the monk)
  • A mural that in a very wide landscape mode that looked something like DaVinci drawings

If anyone knows any of these, let me know.

 

  • UPDATE: This post has become quite popular. Due to this demand, 2 web sites have sprung up as a response. WORLDSUPERHEROREGISTRY.COM founded by Kevlex and superheroes.members.winisp.net founded by yours truly. I didn't create my site as competition for Kevlex but only as a community service to my friends that visit this page. Who knows, maybe Kevlex and I will join forces in the future to create the first true Justice League type organization! :-)

Ok, this is an odd post but something I've always wondered.  Let me begin by saying that my current game that I'm playing for the PC is called “City of Heroes” which is one of those MMORPG's.  It's a great game especially if you're tired of the same old fantasy based game that all other MMO's are.  Let's just hope they start ramping up the content since it only took about 12 days or so for someone to hit the highest level (40).

So I'm sitting at my desk looking at some E3 news when I see an ad for the new Spiderman 2 game coming out (which itself looks awesome too).  I then recalled a question I've asked myself many times in the past: Why aren't there any real life superheroes?  Now, I obviously don't mean people with extraordinary powers like flight or telekinesis. Let's take Batman for instance.  He has no powers.  Everything he has is based on technical gadgets that he can afford due to his wealth.

I went on the web to see if in fact there is some real life person walking around trying to be a superhero.  I found one by the name of “Angle Grinder” but he's boring.  He just goes around and cuts off special locking devices the police put on cars in the UK for some reason.  Another one is named Terrifica (c'mon, can't we think of something more creative) who apparently rescues drunk women from sexual advances or something.  Another story was about a prankster who got the local media and soon the national media to believe that a man with a brown mask is going around some small town rescuing people (but it is just a hoax).

So, where are all the superheroes?  I know there are some seriously crazy people out in the world but there has to be at least one crazy person with brains that can create superhero gadgets ala Batman.  Bonus if someone can find a superhero with their very own web page and/or blog!