代碼: 選擇全部
//模擬最大化的無 caption form
procedure Tform1.Button1Click(Sender: TObject);
begin
SetWindowLong(Handle,GWL_style,GetWindowLong(Handle,GWL_style)and(not WS_CAPTION));
SetBounds( Left - ClientOrigin.X, Top - ClientOrigin.Y, GetDeviceCaps( Canvas.handle, HORZRES )
+ (Width - ClientWidth), GetDeviceCaps( Canvas.handle, VERTRES ) + (Height - ClientHeight ));
end;
//無 caption form
procedure Tform1.Button2Click(Sender: TObject);
begin
SetWindowLong(Handle,GWL_style,GetWindowLong(Handle,GWL_style)and(not WS_CAPTION));
SetBounds( Left , Top , ClientWidth, ClientHeight);
end;
轉貼兩篇參考文章:
http://www.lmc-mediaagentur.de/dpool/tips/0548.htm
How to create a full screen form without auto-hiding the Windows Taskbar
--------------------------------------------------------------------------------
How do I set my form to display in full screen? No title bar, no borders, and it goes over the task bar (not by setting the task bar to "Auto Hide").
Emulating full screen mode:
代碼: 選擇全部
private {in form declaration}
procedure WMGetMinMaxInfo(var msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
procedure Tform1.WMGetMinMaxInfo(var msg: TWMGetMinMaxInfo);
begin
inherited;
with msg.MinMaxInfo^.ptMaxTrackSize do begin
X := GetDeviceCaps( Canvas.handle, HORZRES ) + (Width - ClientWidth);
Y := GetDeviceCaps( Canvas.handle, VERTRES ) + (Height - ClientHeight );
end;
end;
procedure Tform1.Button2Click(Sender: TObject);
const
Rect: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0);
FullScreen: Boolean = False;
begin
FullScreen := not FullScreen;
if FullScreen then
begin
Rect := BoundsRect;
SetBounds( Left - ClientOrigin.X, Top - ClientOrigin.Y, GetDeviceCaps( Canvas.handle, HORZRES )
+ (Width - ClientWidth), GetDeviceCaps( Canvas.handle, VERTRES ) + (Height - ClientHeight ));
{Label2.caption := IntToStr(GetDeviceCaps( Canvas.handle, VERTRES ));}
end
else
BoundsRect := Rect;
end;
http://www.lmc-mediaagentur.de/dpool/tips/0215.htm
How to hide and show the title bar of a Tform
--------------------------------------------------------------------------------
Here is how to hide the titlebar:
代碼: 選擇全部
procedure TYourformName.HideTitlebar;
var
Save: LongInt;
begin
if Borderstyle = bsNone then
Exit;
Save := GetWindowLong(Handle, GWL_style);
if (Save and WS_CAPTION) = WS_CAPTION then
begin
case Borderstyle of
bsSingle, bsSizeable:
SetWindowLong(Handle, GWL_style, Save and (not (WS_CAPTION)) or WS_BORDER);
bsDialog:
SetWindowLong(Handle, GWL_style, Save and (not (WS_CAPTION)) or DS_MODALFRAME
or WS_DLGFRAME);
end;
Height := Height - GetSystemMetrics(SM_CYCAPTION);
Refresh;
end;
end;
代碼: 選擇全部
procedure TYourformName.ShowTitlebar;
var
Save: LongInt;
begin
if Borderstyle = bsNone then
Exit;
Save := GetWindowLong(Handle, GWL_style);
if (Save and WS_CAPTION) <> WS_CAPTION then
begin
case Borderstyle of
bsSingle, bsSizeable:
SetWindowLong(Handle, GWL_style, Save or WS_CAPTION or WS_BORDER);
bsDialog :
SetWindowLong(Handle, GWL_style, Save or WS_CAPTION or DS_MODALFRAME or WS_DLGFRAME);
end;
Height := Height + GetSystemMetrics(SM_CYCAPTION);
Refresh;
end;
end;