Récupérer la hauteur de la barre des tâches

Contenu du snippet

{**
  Variante de mon code precedent en utilisant pas l'objet TScreen mais
  la fonction GetWindowDesktop.
**}

function GetTaskBarInfos(var tbi : TTaskBarInfo) : boolean;
var TR : TRect;
    DR : 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, TR); { @User32.GetWindowRect}
      if result then
      begin
        Left   := TR.Left;
        Top    := TR.Top;
        Width  := TR.Right - TR.Left;
        Height := TR.Bottom - TR.Top;
        GetWindowRect(GetDesktopWindow, DR); { @User32.GetDesktopWindow }
        DL     := DR.Left;
        DT     := DR.Top;
        DW     := DR.Right-DR.Left;
        DH     := DR.Bottom-DR.Top;
        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;


Compatibilité : Delphi 5

Disponible dans d'autres langages :

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.