{**
Petite variante par rapport au code de WhiteHippo
permet de recuperer :
origine (LxT) de la barre des taches
taille (WxH) de la barre des taches
handle de la barre des taches
position (L, T, R, B) de la barre des taches
**}
const
{ utilisé pour la valeur du flag TTaskBarInfo.Position }
TASKBAR_POSITION_UNKNOW = byte($00);
TASKBAR_POSITION_LEFT = byte($01);
TASKBAR_POSITION_TOP = byte($02);
TASKBAR_POSITION_RIGHT = byte($03);
TASKBAR_POSITION_BOTTOM = byte($04);
type
{ utilisé par la fonction GetTaskBarInfos }
TTaskBarInfo = record
Left : integer;
Top : integer;
Width : integer;
Height : integer;
Position : byte;
Handle : HWND;
end;
{ GetTaskBarInfos
Recupere les informations (origine, taille, position, handle) de la barre des
taches de windows.
Params
tbi [O] TTaskBarInfo structure
Return
boolean, true si reussite de l'operation
}
function GetTaskBarInfos(var tbi : TTaskBarInfo) : boolean;
var R : TRect;
DL,DT,DW,DH : integer;
begin
with tbi do
begin
Handle := FindWindow('Shell_TrayWnd',''); { @User32.FindWindowA }
result := Handle <> INVALID_HANDLE_VALUE;
if result then
begin
result := GetWindowRect(Handle, R); { @User32.GetWindowRect}
if result then
begin
Left := R.Left;
Top := R.Top;
Width := R.Right - R.Left;
Height := R.Bottom - R.Top;
DL := Screen.DesktopLeft;
DT := screen.DesktopTop;
DW := screen.DesktopWidth;
DH := Screen.DesktopHeight;
if (Left = DL) and (Top = DT) and (Width = DW) and (Height < DH) then
Position := TASKBAR_POSITION_TOP
else
if (Left = DL) and (Top > DT) and (Width = DW) and (Height < DH) then
Position := TASKBAR_POSITION_BOTTOM
else
if (Left = DL) and (Top = DT) and (Width < DW) and (Height = DH) then
Position := TASKBAR_POSITION_LEFT
else
if (Left > DL) and (Top = DT) and (Width < DW) and (Height = DH) then
Position := TASKBAR_POSITION_RIGHT
else
Position := TASKBAR_POSITION_UNKNOW;
end;
end;
end;
end;