How To Add Form Drop Shadow on Windows XP

This article explains how to manipulate form appearance on Windows XP by adding drop shadow effect. 

Step 1

Create a new form or modify main form. In the form code for example frmShadow, override CreateParams() method with your own.


 TfrmShadow = class(TForm)
  { Private declarations }
  { Public declarations }
  procedure CreateParams(var Params: TCreateParams); override; end

Complete form declaration by pressing CTRL+SHIFT+C. Delphi IDE will add implementaion of CreateParams.

Step 2

Because drop shadow effect will only work on Windows XP or later, you need to make sure that we add drop shadow only when we know the operating system is Windows XP.

function IsWinXP: Boolean; begin

Result:= (Win32Platform = VER_PLATFORM_WIN32_NT) and
          (Win32MajorVersion >= 5) and (Win32MinorVersion >= 1); end

Step 3

Last we add drop shadow effect by modifiying Style of WindowClass bit inside CreateParams.

procedure TfrmShadow.CreateParams(var Params: TCreateParams);
const CS_DROPSHADOW = $00020000;
begin inherited;

if IsWinXP then begin Params.WindowClass.Style := Params.WindowClass.Style or CS_DROPSHADOW; end


Share this article!

Follow us!

Find more helpful articles: