Nick Hodges

TSmiley 2010: The Next Generation in Uselessness

06 Jan

If I had a dollar for every time I’ve been “teased” about TSmiley, I could finance my own startup. 

TSmiley, for those of you that don’t know or haven’t heard, is maybe the very first third-party VCL component ever.  I built it for the first time way back in the fall of 1994 when I was on the original Delphi 1 beta.  The VCL was brand new and in development, and the notion of building a component in Pascal was so cool, I couldn’t resist.  (Remember, those were the days when the only “components” were VBX controls, used in Visual Basic, but written in C++.  Remember when Delphi actually could consume VBX controls?) 

I couldn’t wait to write components, and of course, half the battle is coming up with an idea – not always easy.  Windows95 was brand new at that time, and so was MineSweeper. Remember the old school Minesweeper version, with the little smiley face up there? It was a fun game. MineSweeperI used to play on the smallest size and see how fast I could clear the board.  Anyhoo – I thought it was cool that it has this little smiley on there that would make faces at you if you lost, etc. So I decided to build a Delphi-based version of this little control.

I built the thing with two purposes in mind:  to learn how to build components and to create something that others could learn from.  It started out as a descendant of TImage (made sense at the time — trust me) and I did a few things like override protected methods that fire events, trap and handle Windows messages, etc.  I even figured out how to build a property editor for it. 

I posted it on the Compuserve forums, and the next thing I know, Charlie Calvert, David I, and the Borland gang were all using it in demos all over the world.  It became a pretty good running joke (to this day, Xavier Pacheco still teases me about it.  Let it go, X….) and I sort of ran with it.  I had a press release, I said things like “The usefulness of TSmiley cannot be measured” and I generally rode that handy little component to fame and glory. Okay, maybe not much fame and glory, but it was fun, and I do believe that folks learned a thing or two from it. I mean, the thing was basically useless (though I did have people tell me that they used it in production apps……) but it did show some interesting ways to build components. 

If you want to take a trip down memory lane, a very early version of the TSmiley page is available on the Wayback machine, as is a copy of the “press release” that I wrote. 

Recently, someone on the newsgroups asked if there was a version that worked with Delphi 2010. So I scrounged around and found the code.  I had to blow a few layers of dust off of it, but there it was, sitting on my backup/archive hard drive. I cracked it open, and man, was it embarrassing.  Talk about code that was clearly written back in the early days before I could even pretend that I knew what I was doing. (At least I had changed it to descend from TGraphicControl)  I mean, it worked, and for the time it was written it was pretty well done, but over the years, the “best practices” of component Delphi development have changed, and so it was time to update.

So, update I did.  Here’s a summary of the updates that I made, and some discussion about why.  Hopefully there are some tips in there.

  • First thing I did was notice that I hadn’t followed the DRY (Don’t Repeat Yourself) principle.  There was common code all over, and the bitmaps themselves were in both the runtime and the design-time packages.  It would have been a real pain to add another TSmiley mood, so I added the bitmaps as resources to the runtime packages, I ensured that the design-time package got all of its needed information from the runtime package, and tried to refactor code patterns that repeated themselves. Hopefully thinks are much more efficient.
  • I added a mini-API to TSmiley in the form of some class methods.  These allow you to get a bitmap, a name, and a description for a given Mood from TSmiley without need an actual instance. (For instance, that’s how the
  • I declared all the strings as resourcestring to help anyone that wants to localize TSmiley
  • I updated the Mood property editor.  The original property editor was a series of fixed speedbuttons with the bitmaps on them as glyphs.  This was utterly inflexible, because you had to add another speedbutton if you added a new mood.  Now, theproped. Property Editor is a ListView that dynamically loads up the graphics, names, and descriptions without caring how many there are.  This makes it much easier to add a mood as the new mood will automatically be added to the property editor.
  • I made DoMoodChange virtual.  This means you can more easily override it and add any functionality you might want to a descendent class. It is a good practice to have your events fired in a stand alone, virtual method.  That way, you allow descendent components to easily augment the behavior if desired.  If you have an event called OnMoodChange, it’s good to have a DoMoodChange method that is virtual and does nothing more than fire the event.
  • I stopped trapping and handling WM_PAINT and simply overrode the Paint method.  No need to illustrate how to do that anymore – too old school.  ;-)
  • I published a bunch of events from TControl that didn’t get published by TGraphicControl.  Now you can provide handlers for events like OnMouseOver, OnDblClick, etc.
  • I added the ClickMood property. The original TSmiley would wink at you if you clicked on it, but I figured that the face that shows up when you click should be configurable, so now you can set what mood you want to appear when a user clicks on TSmiley.
  • I added two constant arrays, one for the Mood name and one for the Mood description.  TSmiley will automatically update its own hint with the <short hint>|<long hint> pattern when the Mood is set.
  • I added a small test/demo application that shows how TSmiley might be used, and to verify functionality. Nothing much – it just creates a TSmiley on the fly and toggles the mood, as well as displaying the hints. 

That’s all I can remember right now – there are probably a lot of other subtle changes as well.  I tooled around with it for a while until I felt comfortable with the code.  I’m not claiming it’s any great chunk of code, but it looks “clean” and well organized to me. 

In any event, hopefully this will bring TSmiley into the modern age.  So, how do you get it?  Well, I’ve put TSmiley up on SourceForge, making it easy for you to get and easy for to enhance, fix, and update.  I’m totally open to enhancement ideas, bug reports, etc.   

TSmiley is freeware, so have at it. And don’t worry, I can take all the teasing.  After all, one really can’t describe how useful TSmiley is.

26 Responses to “TSmiley 2010: The Next Generation in Uselessness”

  1. 1
    Jimbo Says:

    Does it take a while of the files to be processed by SourceForge? Just I took a look, and there were no files on the project page…..


  2. 2
    Nick Hodges Says:

    Jimbo –

    I haven’t added any files to the project. You can pull it directly from the Subversion repository.


  3. 3
    TDelphiHobbyist Says:

    Brilliant Nick. I have to have another look at it. Thanks.

  4. 4
    Alexandre Machado Says:

    I don´t want to ruin your happy blog moment Nick but, don´t you guys at Emb have nothing important to say?… let´s say… What about 64 bit Delphi? Let´s say… The day that we in Brazil will pay the same amount of dollars for the same Embarcadero product? Something REALLY interesting like that?
    Anyway, it is nice to see that you guys have plenty of time to spend blogging about TSmiley! :-) I feel really confortable!

  5. 5
    M J Marshall Says:

    NOW I can finally port our applications to Delphi 2010! Lack of TSmiley support has been a real show-stopper for us.


  6. 6
    Brandon Says:

    Alexandre, do you really think Emb paid Nick for this? Ever heard of personal projects? Lighten up.

  7. 7
    Xepol Says:

    Nice sane license conditions I see :-)

  8. 8
    Samir Kumar Mishra Says:

    It does bring a smiley at my end.. Love to use this component sometime soon in our projects :)

  9. 9
    David Keith Says:

    I think you’re longing to be functional again, Nick. Or is this your way of indulging your mid-life crisis? A sort of therapy for middle aged programmers who don’t get to see much action any more?

    Mid-Lifer longing for the glory days << :-)

  10. 10
    Xepol Says:

    Just a thought Nick -> It might be time to convert the help file into the new help format.

  11. 11
    Paweł Głowacki Says:

    TSmiley truely rockz! I do not believe there is anything else out there that could compete with Delphi in terms of component development.
    I miss mentioning that in Delphi 1 one had to recompile the whole VCL to get a component installed:-)

  12. 12
    Alan C Says:

    Will there be a Delphi Prism version? I have several customers asking for this.

  13. 13
    Anon Says:

    You should publish the original code as well. It could be very useful to see the enhancements.

  14. 14
    Nick Hodges Says:

    @Xepol –

    I’m lucky to have that help file. ;-) The source for it is long gone. I’ll look into totally brand new docs.


  15. 15
    Xepol Says:

    Source code for old style help files? Nothing simpler - check your email Nick.

  16. 16
    Alexandre Machado Says:

    @Brandon: Nothing against personal projects. Once Nick is not paid to blog, or to re-create a TSmiley component, I’m humbling suggesting - keeping in mind that he loves his job and he loves Delphi - that maybe he can use his personal projects doing something useful, or even better, talking about something interesting for Delphi developers.
    Besides that, I’ve been told several times that we should not rant about something related to Delphi in the Emb forum: Emb guys are "too busy" doing other things and they just won’t read it, will they? So I guess that Delphi’s product manager blog should be a more appropriate place to rant. Did I guess it right?

  17. 17
    David Intersimone Says:

    I, for one, think the updating of the implementation of a component that was written years ago, is a great educational tool for component developers and application developers (who use components) to learn what it takes to migrate old components to 2010. I also think there is a lot to be learned from Nick’s advice about the modern ways (and new Delphi language and component features) to design components.

    This will help a lot of developers and component designers. Heck, it could be a long form article, or even a book on Delphi component development and migration.

    Thank you Nick!

  18. 18
    Troy from Iowa Says:

    Nick I do remember something about TSmiley. When a array must be less than 65535 characters. (or something like that). Keep up the great work. I hope dephi adds a Gaming component. Use the Gesture, and the new directx In Delphi 2010 to make a framwork for a gaming interface

  19. 19
    Hristo Says:

    Nick, you have made the DoMoodChange method virtual but it is still in the private section of the class ;)
    And as I know the convention in VCL is methods that fire events to be marked ‘dynamic’, not ‘virtual’.

  20. 20
    Nick Hodges Says:

    Hristo –

    Doh! What a bone-head I am! Thanks –

    Fixed on SVN. I’ll get a new ZIP file up soon.


  21. 21
    Mike Rozlog Says:


    The awesomeness of the component is staggering and the best thing about it is that it works, every single time, as expected! :-) Actually, I think it is a really cool way to show how to do things with a lot of new features and the write-up explaining the refinement process is perfect for teaching how to do refactoring.

    Great Job,


  22. 22
    Nick Hodges Says:


    My man! You need to email me –

    We have to catch up.


  23. 23
    Hugh Brien Says:

    I think I could be one of the original users of TSmiley. I am still a huge Delphi fan however it’s been a while since I had the opportunity to program in it. Delphi is the greatest Win16/32 development environment ever created.
    Nice job Nick. In 2005, I build an IM like widget for generating desktop alarms for a performance product I worked on at Wily.

    I wrote it in 4 hours. It was really fun.

    Take Care,

    Do you ever see/talk to anyone from NPS?

  24. 24
    Warren Says:

    All the strings are in resource format so it can be localized. Great.

    Some one in the community should go ahead and localize. Can we get some volunteers?

    Let’s see. German, Chinese, Russian, and French, at least?


  25. 25
    Книги » DirectX и Delphi. Искусство программирования (+ CD-ROM) читать, купить, смотреть онлайн – Михаил Фленов Says:

    [...] Nick Hodges » Blog Archive » TSmiley 2010: The Next Generation in Uselessness [...]

  26. 26
    Flotsam and Jetsam #96 | Delphi-losophy Says:

    [...] buttons.  I was also honored to be interviewed for the event, talking about the early days of TSmiley and something I’m still proud of to this day – the fact that I was at the original launch event [...]

© 2016 Nick Hodges | Entries (RSS) and Comments (RSS)

Your Index Web Directorywordpress logo