在frmMain中加入:
function TfrmMain.DefineArea: Boolean;
var
hApp: HWND;
rcApp, rcWork: TRect;
begin
rcWork.Top:=0;
rcWork.Left:=0;
rcWork.Bottom:= GetSystemMetrics(SM_CYSCREEN);
rcWork.Right:= GetSystemMetrics(SM_CXSCREEN);
hApp := FindWindow('Shell_TrayWnd', '');
if hApp <> 0 then begin
{ get the size of the taskbar }
GetWindowRect(hApp, rcApp);
{ cut the workarea to place the taskbar }
if rcApp.Right<rcWork.Right then
rcWork.Left:=rcApp.Right; { bar on left edge }
if rcApp.Bottom<rcWork.Bottom then
rcWork.Top:=rcApp.Bottom; { bar on top edge }
if rcApp.Left>0 then
rcWork.Right:=rcApp.Left; { bar on right edge }
if rcApp.Top>0 then
rcWork.Bottom:=rcApp.Top; { bar on bottom edge }
end;
{ set workarea }
Constraints.MaxHeight := rcWork.Bottom - rcWork.Top;
Constraints.MaxWidth := rcWork.Right - rcWork.Left;
end;
在FormCreate中调用就行了