Mirror

Add a drop shadow to your app under XP (Views: 100)


Problem/Question/Abstract:

Add a drop shadow to your app under XP

Answer:

Heres a nice way of adding a drop shadow to your application under Windows XP.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  protected
    procedure CreateParams(var Params: TCreateParams); override; // Important !
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

{------------------------------------------------------------}
// Here we check of the user is running Windows XP

function IsWinXP: Boolean;
begin
  Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and
    (Win32MajorVersion >= 5) and (Win32MinorVersion >= 1);
end;
{------------------------------------------------------------}

{------------------------------------------------------------}
// Check if it is Windows XP if all is OK then create the drop shadow

procedure TForm1.CreateParams(var Params: TCreateParams);
const
  CS_DROPSHADOW = $00020000;
begin
  inherited;
  if IsWinXP then
    Params.WindowClass.Style := Params.WindowClass.Style or CS_DROPSHADOW
  else
end;
{------------------------------------------------------------}

end.

This code also checks if it is running under Windows XP, if it is you get the drop shadow if not it does nothing.

<< Back to main page