Thursday, January 31, 2008

Color MDI Form

If we want to change background color of a form: we usually do like this:
 Form1.Color := clYellow;
However, if a Form's FormStyle is fsMDIForm, change the color at runtime will not update immediately not until the form has been fully repaint or resize. Invoke TForm.Refresh, TForm.Update, TForm.Repaint will not update the color as well. To make the a MDI form update the background color immediately, we may do this:
 Form1.Color := clYellow;
 Windows.InvalidateRect(Form1.ClientHandle, nil, True);

Thursday, January 24, 2008

How to avoid creation of ~BPL files in Delphi 2007

There is only one way to prevent creation of ~BPL in Delphi 2007 IDE: patch delphicoreide100.bpl in C:\Program Files\CodeGear\RAD Studio\5.0\bin. A good news is someone from has wrote Delphi Distiller to patch the delphicoreide100.bpl. Hope CodeGear will provide an option in Delphi IDE to turn on and off the creation of ~BPL soon.

Thursday, January 17, 2008

Setup Visual Studio 2005 to build Firebird source

Due to I/O redirector problem in GBAK.EXE (, I download Firebird source to attempt compile it under Visual Studio 2005. Here are the steps:
  1. Install Visual Studio 2005
  2. Read the instruction in firebird source folder: doc/
  3. Install Firebird server
  4. Setup these environment variables:
    1. FIREBIRD=C:\Program Files\Firebird\Firebird_1_5
    3. ISC_PASSWORD=masterkey
    4. LIB=C:\Program Files\Microsoft Visual Studio 8\VC\lib
    5. PATH=C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\bin
  5. Open file "builds\win32\blrtable.BAT", add an include path: -I"C:\Program Files\Microsoft Visual Studio 8\VC\include" to the cl.exe clause
  6. Open folder "builds\win32\msvc7", convert 2 solution files: Firebird2.sln and Firebird2Boot.sln to Visual Studio 2005 solution format.
  7. Execute cmd.exe, and run Prepare.BAT, make_boot.BAT and make_all.BAT

Wednesday, January 16, 2008

Embed out of process windows into Delphi Control

We may easily embed a Delphi GUI control into another container control like TForm or TPanel:
var F: TForm;
  B: TButton;
F := TForm.Create(nil);
B := TButton.Create(nil);
B.Parent := F;
As TForm or TPanel is a Window GUI control too, we may embed a non-delphi out of process windows into TForm or TPanel control too:
var F: TForm;
   H: THandle;
   T: Cardinal;
 F := TForm.Create(nil);

 ShellExecute(0, 'open', 'calc', nil, nil, 0);

 // New window may not be created yet, find the window in a loop until it show out
 H := 0;
 T := GetTickCount;
 while H = 0 do begin
   H := FindWindow(nil, PChar('Calculator'));
   if GetTickCount - T > 5000 then

 if H <> 0 then
   Windows.SetParent(H, F.Handle);