We help IT Professionals succeed at work.

Win2000 Taskbar

totok
totok asked
on
Hi,

I just wonder, how I can make my Win2000 taskbar transparent by using Delphi 5.

Thank you for your help.
Comment
Watch Question

Commented:
Hi,
heres a way to do that:
Regards Barry

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  taskbarhandle : HWND;

implementation

{$R *.DFM}

const
  WS_EX_LAYERED = $80000;
  LWA_COLORKEY = 1;
  LWA_ALPHA    = 2;

type
 TSetLayeredWindowAttributes = function (
            hwnd : HWND;
            color : COLORREF;
            bAlpha : byte;
            dwFlags : DWORD
            ): BOOL; stdcall;

procedure TForm1.FormCreate(Sender: TObject);
var
  Info: TOSVersionInfo;
  F: TSetLayeredWindowAttributes;
begin
taskbarhandle := FindWindow('Shell_TrayWnd', nil);
inherited;
  begin
  Info.dwOSVersionInfoSize := SizeOf(Info);
  GetVersionEx(Info);
  if (Info.dwPlatformId = VER_PLATFORM_WIN32_NT) and
(Info.dwMajorVersion >= 5) then begin
    F := GetProcAddress(GetModulehandle(user32),
'SetLayeredWindowAttributes');
    if Assigned(F) then begin
  SetWindowLong(taskbarhandle,GWL_EXSTYLE, GetWindowLong(taskbarhandle,
GWL_EXSTYLE) or WS_EX_LAYERED);
 F(taskbarhandle,ColorToRGB(clred),170 , LWA_ALPHA);
    end;
  end;
end;
end;

end.

Commented:
quite a cool effect ,you can see other programs like windows explorer's taskbar captions through the main taskbar :-)

Commented:
Hi Barry,

are you sure that this works? Normally SetWindowLong works only for windows that belong to your own process. Did you perhaps test it with my components (they internally do some hacks to make SetWindowLong work for other processes, too)?

Regards, Madshi.

Commented:

Commented:
hi madshi,
well spotted , the SetWindowLong() call shouldnt be there,
i cut n pasted the function from a db app of mine and without looking properly just replaced all the instances of h (my db's form handle) to taskbarhandle :-)

Totik,
remove the setwindowlong line ,its not needed and note it fails unless you have madshis comps installed.

Cheers Barry

Commented:
i mean the function still works but the setwindowlong call wont (or shouldnt :)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.