bsNone的窗体,最大化时怎样才能不覆盖状态栏???(50分)

Y

yeath

Unregistered / Unconfirmed
GUEST, unregistred user!
bsNone的窗体最大化时,怎么样才能不覆盖状态栏,像bsSizeable的窗体一样。
 
在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中调用就行了
 
接受答案了.
 
顶部