Archive for November, 2007

CodeRage II is a Success

Friday, November 30th, 2007

Wow, what a week. CodeRage II went great. A lot of good content and I enjoyed presenting my sessions. You can get the code, links, etc. from them here:

They all went really well I thought. Unfortunately I pushed the deadline back too far on Delphi Robot Rage and my JIT Presentation didn’t happen on time. Sorry to everyone about that.

Check back often for updates (seriously), or let me know if I missed something you are looking for from my sessions.

Thanks!

Crashing Like VB

Wednesday, November 28th, 2007

I always thought Delphi’s global exception handler was a great feature. It allows your program to continue after an otherwise unhandled exception would have caused it to terminate. Typically in a serious application you would assign your own global exception handler, or used one of the great 3rd part exception handlers like madExcept or Exceptional Magic (I love that name!) They both provide a nice dialog, stack trace, logging and reporting.

Well it turns out that if you want to be Microsoft Windows Vista Logo certified, then you need to crash your application on certain exceptions.

Applications must handle only exceptions that are known and expected, and Windows Error Reporting must not be disabled. If a fault (such as an Access Violation) is injected into an application, the application must allow Windows Error Reporting to report this crash. (from requirement 3.2 Resilient Software: Eliminate Application Failures)

Microsoft’s rational for this requirement is the ISV will receive the error report Microsoft collects for them. I guess most software developers don’t have access to tools like we do in Delphi to catch exceptions and log them for us.

So short of tossing out the Forms unit and writing everything from scratch, how can you get around the usefulness of the global exception handler.

My first thought was to create a custome application exception handler by placing a TApplicationEvents on your main form and assigning the OnException event. In the event include the line

  raise e;

This will pass an exception up to the operating system and terminate your application, at least when I tested it in Delphi 2007. When I tried it in Delphi 7, it didn’t work right.

A more elegant and involved solution:

First you need a couple global variables:

var
  GlobalExcept: Exception;
  GlobalExceptAddr: Pointer;

And a global exception handler:

procedure TForm1.ApplicationException(Sender: TObject; E: Exception);
begin
  if E is EAccessViolation then
  begin
    // Keep the exception object from being destroyed!
    AcquireExceptionObject;
    GlobalExcept := e;
    GlobalExceptAddr := ExceptAddr;
    Application.Terminate;
  end;
end;

The rest of the magic happens in the project file (DPR)

begin
  GlobalExcept := nil;
  GlobalExceptAddr := nil;
  try
    Application.Initialize;
    Application.CreateForm(TForm1, Form1);
  Application.Run;
  finally
    if Assigned( GlobalExcept ) then
    begin
      raise GlobalExcept at GlobalExceptAddr;
    end;
  end;
end.

And you can [download the code].

Thanks to Jeremi Reda for asking this question in borland.public.delphi.non-technical.

I didn’t cover this in my CodeRage II session on Exceptional Exceptions, but there is a lot of other cool stuff, like AcquireExceptionObject!

WordPress upgraded to 2.3.1

Monday, November 26th, 2007

I finally upgraded to WordPress 2.3.1 from an earlier version. Now I have official tag support, unfortunately I have been using categories for tags. Now I need to clean up my category list and change everything to be tagged instead. I am sure there will be other changes too.

10 Top Things Added to Delphi Since Delphi 7

Monday, November 26th, 2007

The session “Leveraging What You Have: 10 Top Things Added to Delphi Since Delphi 7″ by Pawel Glowacki was one I was looking forward too. The audio and video quality was a little poor, so I skipped it to watch later when I had more time. Pawel posted his list though, with a lot of details. That is probably more valuable to me then the video session. If the video was chopped up by list item so I could jump to a feature I was unfamiliar with, that would be really cool.

There are a lot of really cool enhancements since Delphi 7. I know a lot of people were holding out on Delphi 7 because it was such a solid release. Delphi 8 was .NET only, and of questionable stability. Since then each release has gotten much better. I must say, Delphi 2007 is definitely worthy of an upgrade from Delphi 7.

Attending CodeRage II

Monday, November 26th, 2007

So I am breaking the cardinal rule of attending a virtual developers conference: multitasking. Sure, that is one of the advantages, but at the same time, it really detracts from how much you get from the conference if you are are tying to do your job at the same time (not to mention it detracts from your job performance). Normally I would commit some time, but we are on a serious deadline right now, so I am getting it done.

As a result I am skimming many of the sessions. I’ll catch them on replay.

Free Camtasia and Snagit

Monday, November 26th, 2007

When it comes to screen capturing, Techsmith’s products Camtasia and SnagIt are probably the best, but there are good free alternatives. It would appear if you know where to go (links at the bottom), you can get a legitimate free license for Camtasia and SnagIt (earlier versions at least, that are eligible for a discounted upgrade.)

Camtasia is a screen video capture tool. It produces a video (animated GIF, SWF, AVI, etc.) from a series of screen shots over a period of time, usually with audio. It has a lot of nice extras and a good editing system. DebugMode’s Wink is a great tool for free. While Camtasia is more like a video editor, Wink is more like a slide show editor. It will take a screen shot at a keypress, mouse click or automatically at specified intervals. Then the editor is based on individual screen frames instead of a sequence of video. While it some regards it competes with Camtasia, it serves a different purpose as well. Worth checking out, especially at the price.

SnagIt is a single frame screen capture tool. Typically I just use [Print-Screen] or [Alt] + [Print-Screen] to capture the whole screen, or just the current window respectively. Then I paste it into IrfanView (a great quick image viewer, editor and converter) to make any changes necessary. Honestly though, SnagIt offers a number of additional features that are worthwhile. However I have found that MWSnap has most of the features I need available free. I haven’t done a side by side comparison of the tool, but I imagine MWSnap would hold up quite nicely.

With free versions of SnagIt and Camtasia though, that provides some stiff competition to the other free versions. Granted these are previous versions, which is risky on Techsmith’s part, since the biggest competitor to most products is its previous version – why pay the upgrade fee when the old version still works?  If you want an older version of many freeware / shareware titles, check out OldVersion.com.

Camtasia Studio 5 (the version I have) is $300 and has a lot of nice feature upgrades from version 3.  You can still download version 3 and then get your free license straight from Techsmith.  It appears it was a promotion offered to PC Plus Magazine readers in the UK, but the form lets you specify any country and I don’t see anywhere it says “only” a limited group.  Not sure how long the promotion is good for either. [Source]

Check out Digital Inspiration Technology guide for the details on downloading and getting a free license for SnagIt 7.2.5 (current version is 8). It appears to be a free promotion for UK .NET Magazine.

D-Robots and Delphi Robot Rage

Tuesday, November 20th, 2007

The last session of CodeRage ][ (now FREE!) is the Delphi Robot Rage. This is your opportunity to show off your amazing Delphi programming skills. Download D-Robots and build your robot to compete in a Death Match on the Light Plaza map against one or more robots created by other participants. There will be amazing prizes (undisclosed as of yet), but of course the best prize will be having your amazing programming skills shown off to the world.

Requirements:

  1. Robot must have unsecured source (no password, or password must be provided), although the source will not be revealed until after the challenge is completed.
  2. If a unique skin is not used for your robot, then a new skin may be assigned to your robot for visual identification.
  3. Competition is open to everyone. No purchase necessary. Not required to be in attendance at CodeRage II to enter or win, although that is the best way to see the action!
  4. Email your robot to me (delphirobotrage@davinciunltd.com), and I will reply with acknowledgment. If I don’t reply, I didn’t receive it.

Deadline for submissions: November 26th, 2007 – midnight Pacific Time

Notice: There is an incompatibility between D-Robots and some video drivers (maybe just ATI). No known work around. It does work in a virtual machine, but your frame rate will be very poor.

If you submit your robot early enough, you might get some feedback from a practice round.

Short intro video online & Partial list of prizes.

Questions? Comments?

CodeRage II

Monday, November 12th, 2007

CodeRage II

Be sure you are registered to attend CodeRage II. This is CodeGear’s second virtual developers conference. Being virtual it is a whole lot cheaper and easier to attend. The key is to actually schedule time to watch sessions and be sure you are not working or otherwise distracted. If you are overseas that gets even more interesting.

You can always catch the replays later, but then you miss out on the live chat and Q&A session. I must admit, as a presenter it is odd being in the chat room with the attendees while you are presenting – you are both the presenter and the “peanut gallery” at the same time.

You’ll see sessions on Delphi, Ruby, Java, PHP, C++, Databases, .NET, Win32 and all the latest CodeGear tools and technologies.

I’ll be attending and presenting both. I hope to see you there, virtually of course!

Just Talking to My Self

Wednesday, November 7th, 2007

There is something rather trippy about debugging a server that opens a socket and talks to itself.  Have to pay really close attention or Delphi will trace back into the server again, and all of a sudden you are someplace entirely different in the application.  Of course if you have a break point that gets triggered by the connection you had better disable it before you connect again.

Now to figure out if the server can get the information it needs from itself without going through a socket connection to itself.  I can see that being a bad scenario if it keeps opening new sockets back to itself again. . . .

Almost as much  fun as leaving comments and ping backs on your own blog.

Turbo Pascal 1.0 Floppy

Friday, November 2nd, 2007

I was giving out a couple boxes of old Delphi and Turbo Pascal books last night at the users group. I have this habit of leaving odd things in books though, including large sums of money, so I have taken to inspecting my books before giving them away. A lot of them had the original CD’s or 3.5″ floppies (yes, that old) that came with them. One of them did have an unexpected bonus though.

Turbo Pascal 1.0 5.25″ Floppy Disk

A Turbo Pascal 1.0 floppy (5.25″ even!) Notice the lack of version number, and the copyright date of 1983. It is for IBM PC & Compatibles, not CP/M. You can download the contents of the disk for free, but it is kind of cool to have one of the actual disks.