If you can not edit the Style using BitmapStyleDesigner
, there is a (Technical Arrangement) way to do it.
You must add TPanel
with Height
of +/- 32 (it is at your discretion) with Align = alTop
.
In this Panel you will add the buttons you want (I recommend TSpeedButton) with Align = alRight
, placing the always arranged buttons on the Right if you hide some or resize the window they will automatically aligns, originals.
Now set the BordeStyle
of the Form to bsNone
.
For the close button use Close
For the Minimize Button, use Application.Minimize
For the Restore / Minimize:
if (Nome_Form.WindowState = wsMaximized) then
begin
Nome_Form.WindowState := wsNormal;
{altere a imagem do botão aqui para a que desejar}
end
else
begin
Nome_Form.WindowState := wsMaximized;
{altere a imagem do botão aqui para a que desejar}
end;
Now just add the additional buttons you want,
Work, but if it is the last option you will notice that the result is TOP.
Edit 01: Moving the Form:
In the Panel's OnMouseDown Event (which is now its Title bar):
begin
if (Button = mbLeft) then
begin
ReleaseCapture;
Perform(WM_SYSCOMMAND,$F012,0);
end;
Edit 02: Resizing the Form:
Declare in Private: procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
procedure Nome_Form.WMNCHitTest(var Msg: TWMNCHitTest);
var
ScreenPt: TPoint;
begin
//inherited;
ScreenPt := ScreenToClient(Point(Msg.Xpos, Msg.Ypos));
if (ScreenPt.x < 5) then
Msg.Result := HTLEFT
// top side
else if (ScreenPt.y < 5) then
Msg.Result := HTTOP
// right side
else if (ScreenPt.x >= Width - 5) then
Msg.Result := HTRIGHT
// bottom side
else if (ScreenPt.y >= Height - 5) then
Msg.Result := HTBOTTOM
// top left corner
else if (ScreenPt.x < 5) and (ScreenPt.y < 5) then
Msg.Result := HTTOPLEFT
// bottom left corner
else if (ScreenPt.x < 5) and (ScreenPt.y >= Height - 5) then
Msg.Result := HTBOTTOMLEFT
// top right corner
else if (ScreenPt.x >= Width - 5) and (ScreenPt.y < 5) then
Msg.Result := HTTOPRIGHT
// bottom right corner
else if (ScreenPt.x >= Width - 5) and (ScreenPt.y >= Height - 5) then
Msg.Result := HTBOTTOMRIGHT
end;
Note: The procedure statement that resizes must be the same, different from the procedure body, as if it were sending SendMessage
to the Api of Windows!
That way even the Mouse Cursor will change shape as you approach the form border!
Edit 03: New Container
Now as the Form has no border, we need to create a new Container for the components that need to be aligned using for example the alClient, alLeft etc ...
No OnResize
of Form:
Panel_Principal.Left := 5;
Panel_Principal.Top := 5; {observar o outro panel que é a barra de Título}
Panel_Principal.Width := Nome_Form.Width - 10;
Panel_Principal.Height := Nome_Form.Height - 10;
In this way the Main_Panel and the Form will create the effect of the border.
Important: To not have this hassle all in all forms, you should use this as a Model and the others use as Inheritance. However, for each new form in OnResize
you should program again the same OnResize
.