Monthly Archives: October 2006

Using code browsing in the Delphi IDE

Are you familiar with the code browsing features in the IDE? Code browsing was added several releases ago but I’m not sure if people are familiar with how it works. The idea is pretty simple, leverage standard web browser techniques to allow people to browse their code. The IDE supports both keyboard and mouse navigation for code browsing and from the code editor the options are as follows:

  • Using the mouse, hold down the Control key and click a symbol
  • Using the keyboard position the editor caret on the symbol and press Alt-Up arrow

To complete the browsing metaphor the IDE also supports the standard browse forward/backwards shortcuts of Alt-Left arrow and Alt-Right to navigate the code browsing history just like a web browser.

I’m guesing but probably a much less well known method of code browsing is supported is in the Code completion listbox. To see this, simply position the editor caret inside of a method body and invoke code completion. Once the list appears control click an identifier from the list to browse to that symbol. So, if you find something in the list and you’re wondering “hey, where/what is that?” just control-click it to find out.

UPDATE: In response to a comment to this post I just wanted to mention that IMO code browsing works better in BDS 2006 than any previous release and I know there were a number of bugs fixed specifically related to code browsing.

Using FeedBurner for your RSS feed

As I’ve mentioned previously one of the many reasons I decided to “go it alone” with my blog and move from was the lack of site usage statistics including usage of my $g(RSS feed). Of course, I could provide only excerpts in my feed forcing readers to click through the site but I personally won’t subscribe to non-full text feeds so I can’t really expect that of anyone reading my blog.

That’s where FeedBurner comes in. When $g(Scott Hanselman) mentioned it here I headed over to check it out and now they host my RSS feed providing me with all sort of stats on it’s usage. They even provide web site services for example, I can place what they call a chicklet like this on my blog that displays the number of current subscribers for that day. I can also get information on:

  • Which feed readers are used and how often, 15% of my readers are using $g(FeedDemon) and 13% use $g(bloglines) (my favor RSS reader)
  • How many times an item is clicked
  • How many clicks have occurred within the last hour

The list goes on and on. In addition, FeedBurner provides ways to “Optimize” your feed with a whole slew of services that make your feed more useful and user friendly. For example, if you look at the bottom of this entry you’ll likely see links for “Email this”, “Add a comment”, “Add to” and “Digg this”. All of these are what FeedBurner calls $g(FeedFlare) which you can enable once you’ve $g(burned your feed). They even offer a “Pro” level of statistics for those people seriously addicted to numbers breaking things down even further. So, if you publish an RSS feed you should consider “burning” it with FeedBurner.

UPDATE: I totally forgot to mention, FeedBurner also handles the email subscriptions to my RSS feed.

Calling France

While my blog was hosted on the Borland blog server I was unable to get any real statistics about the usage of my blog which was one of the reasons I decided to host it myself. I’m now using Google Analytics to track site usage and find out what sort of reach my blog has. All I can say is WOW what an eye opener! I had no idea my blog was read in so many different countries around the world. If I knew for sure that it wasn’t against Google’s TOS I’d post a screenshot of the world map with indicators of all the locations.

However, one thing struck me as somewhat odd, not one click has come from France. AFAICT, there are hits from all of the neighboring countries so it seems a little odd that France has none especially considering Europe is where my blog is most widely read. So, here I am, left scratching my head.

Anyway, if you are interested in tracking the usage of your site I’d highly recommend Google Analytics.

Lastly, it’s interesting to know that FireFox, my favorite browser, is beating IE 48% to 42%.

Submit errors and losing all the text in HTML form memo fields

Have you ever spent time and in some case a considerable amount of typing an email or any paragraph of text for that matter in an HTML memo field only to click submit and be greeted with an error page. You tap the back button to return to the form you just submitted and find your memo text is blank! In my case, the simple one line edit fields still have their submitted value but the memo field(s) are blank. That kills me.

My new blog engine, DasBlog, suffers from this very problem. I login, add a new entry, get called away, return to finish up and click “Post to weblog”. I’m greeted with an error page stating something like “You cannot access this page” as a result of my login session timing out. Someone has already logged a bug on the duration of the login session for DasBlog being too short here. But to me the killer problem is the loss of my content. At the very least, I’d expect the error page to include a memo that contains the text of my blog entry and a label reading “BEFORE YOU LOSE ALL THIS TEXT COPY THE FOLLOWING MEMO TO THE CLIPBOARD”.

I know this isn’t really a DasBlog problem and I think web browsers really should have some built-in mechanism to deal with this situation generically. Perhaps there is some FireFox extention that does this and if so, I’d love to hear about it.

Btw, while writing this entry I was called away twice.

Calculating process CPU usage

Recently, I needed a routine to calculate CPU usage so that I could detect when a process went idle. As usual a quick search on Google Groups turned up the answer in this post. The routine calls GetProcessTimes then sleeps for a brief period, calls it again and calculates the average over that interval. The only change I made was to take into account the number of CPU’s on the system by calling GetSystemInfo and divide accordingly.

Will we ever ship Zombie our internal GUI automation framework?

Zombie is not available outside of Borland and at present, not currently part of the Highlander schedule. I’ve been wanting to ship it since about 1995-96 and in fact, made a few attempts at trying to get it to become a product though, as you can tell, didn’t get very far. That doesn’t mean it will never see the light of day outside the walls here in Scotts Valley but it’s not currently on our Roadmap.

There are many people here who are well aware of the power and utility of Zombie though “productizing” it would take time and resources particularly in documenation considering it’s a coders testing tool as there are no record/playback capabilities. In fact, this is considered one of Zombie’s main drawbacks in that there really isn’t any easy way to simply record a test and play it back at least not at the present time.

VCL Forms that snap to the edge of the screen

I was just reading this article over on about getting forms to snap to the edges of the screen. Since at least Delphi 7 this functionality has been built into the VCL and is available through two properties on TCustomForm called ScreenSnap and SnapBuffer.

  • ScreenSnap is a boolean and toggles the feature on/off.
  • SnapBuffer is the distance in pixels from the edge of the screen that you want snapping to occur, the default is 10 pixels.

Automating popup windows and dialogs

I’ve been discussing Zombie, our internal testing framework and last time I talked about generating and using models which are classes used to drive a UI. Previously, I gave an example of a simple model that had a constructor called Connect. One reader, Eric Fortier commented asking how is the Connect constructor used? That’s a really good question.

The Connect constructor is a model specific override that looks like this:

constructor TMyFormModel.Connect;
  inherited ConnectTo('TMyForm', nil);

Of course, the next question is what does ConnectTo do? Well, as you can see it takes the classname of the form that’s modeled, the second parameter is for the caption but typically it’s not required so for  generated models it’s always nil. The ConnectTo constructor uses a special “wait” function which is similar to the Windows FindWindow API call but has the ability to continue searching for a window for a period of time before giving up or timing out. In fact, our framework has a whole set of Wait routines that use our own FindWindow replacement built on top of EnumWindows and EnumChildWindows that supports things like partial matches on window captions and limiting the search to only windows which  are visible to name only two.

Once the window in question has been located the model initializes all of the GEMs, or individual component models necessary to drive the windows various UI elements then calls Bind. The Bind method hooks up the mechanism used for the model to inspect the Window at a deeper level for example the RTTI of the object that instantiated the window. Binding to a window is a complicated process and it’s where the real power of the Zombie framework together with the VCL framework is  derived.