Author: Jonas Bilinkevicius
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.
1 unit Unit1;
2 3 interface4 5 uses6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
7 8 type9 TForm1 = class(TForm)
10 private11 { Private declarations }12 public13 { Public declarations }14 protected15 procedure CreateParams(var Params: TCreateParams); override; // Important !16 end;
17 18 var19 Form1: TForm1;
20 21 implementation22 23 {$R *.DFM}24 25 {------------------------------------------------------------}26 // Here we check of the user is running Windows XP27 28 function IsWinXP: Boolean;
29 begin30 Result := (Win32Platform = VER_PLATFORM_WIN32_NT) and31 (Win32MajorVersion >= 5) and (Win32MinorVersion >= 1);
32 end;
33 {------------------------------------------------------------}34 35 {------------------------------------------------------------}36 // Check if it is Windows XP if all is OK then create the drop shadow37 38 procedure TForm1.CreateParams(var Params: TCreateParams);
39 const40 CS_DROPSHADOW = $00020000;
41 begin42 inherited;
43 if IsWinXP then44 Params.WindowClass.Style := Params.WindowClass.Style or CS_DROPSHADOW
45 else46 end;
47 {------------------------------------------------------------}48 49 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.