Archive for July 17th, 2008

Making a Splash Screen

I’m using splash screen for quite a while. But to realize I’m doing it in a very wrong way is another.

I usually used my Splash Screen as the main form (Since it’s the first one to show up). The problem is I can’t CLOSE it (by doing that will also close the application), and I looked like a totally script kiddies when my code is published. Only God knows what kind of mayhem I produced by using such technique.

Here’s how to make a better (and professional) splash screen :D

Dynamic Object Creation

It’s been days since I’m working on a bug which always generates Access Violation errors.

By slicing and analyzing the pattern, this error always occurs when I’m trying to Free and NIL an object. I’m pretty much confident for the array index, so it should not be the reason for this error.

procedure FreeButtons(Buttons: TButtons);
var
  Cnt : integer;
begin
  for Cnt := Low(Buttons) to High(Buttons) do begin
    FreeAndNil(Buttons[Cnt]);
  end;
  SetLength(Buttons, 0);
end;

This error appears after I ported my old SDI framework into an MDI one. It works perfectly fine earlier, but now definitely gives me some headache. I vaguely presume the reason behind this is the component ownership, but I still hasn’t convinced yet.

Then I stumbled on an article at http://delphi.about.com/od/kbcurt/a/dynamiccreation.htm about dynamic object creation. This article point out that if we’re going to free an object later, we should assign NIL as its parent.

Read more »