Need FMX Styles from DelphiStyles!
unit resizekit; // I wrote self for Xe10.3 rio // Igor Emelyanov
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TResizeFormPos = (rpDefault, rpTopLeft, rpTopCenter, rpTopRight, rpMiddleLeft,
rpMiddleCenter, rpMiddleRight, rpBottomLeft, rpBottomCenter, rpBottomRight);
type
TresizeKit = class(TComponent)
procedure SubclassedParentWndProc(Sender: TObject;
var NewWidth, NewHeight: Integer; var Resize: Boolean);
constructor Create(AOwner: TComponent); override;
private
FOldWindowProc: Controls.TCanResizeEvent;
FFormPos: TResizeFormPos;
FFormWidth, FFormHeight, FFormMaxWidth, FFormMaxHeight, FFormMinWidth,
FFormMinHeight: Integer;
FResizeFont: Boolean;
FNoResizeFntCtl: string;
FNoResizeCtl: Boolean;
FEnabled: Boolean;
FValidTaskbar: Boolean;
procedure SetEnabled(aEnabled: Boolean);
published
property FormPos: TResizeFormPos read FFormPos;
property FormWidth: Integer read FFormWidth;
property FormHeight: Integer read FFormHeight;
property FormMaxWidth: Integer read FFormMaxWidth;
property FormMaxHeight: Integer read FFormMaxHeight;
property FormMinWidth: Integer read FFormMinWidth;
property FormMinHeight: Integer read FFormMinHeight;
property ResizeFont: Boolean read FResizeFont;
property NoResizeFntCtl: string read FNoResizeFntCtl;
property NoResizeCtl: Boolean read FNoResizeCtl;
property Enabled: Boolean read FEnabled write SetEnabled;
property ValidTaskbar: Boolean read FValidTaskbar;
property DesignFrmW: Integer read FFormMinWidth write FFormMinWidth;
property DesignFrmH: Integer read FFormMinWidth write FFormMinWidth;
property DesignDpiW: Integer read FFormMinWidth write FFormMinWidth;
property DesignDpiH: Integer read FFormMinWidth write FFormMinWidth;
end;
procedure Register;
implementation
constructor TresizeKit.Create(AOwner: TComponent);
begin
inherited;
FOldWindowProc := TForm(AOwner).OnCanResize;
SetEnabled(Enabled);
end;
procedure TresizeKit.SetEnabled(aEnabled: Boolean);
begin
FEnabled := aEnabled;
if Enabled and NOT(csDesigning in ComponentState) then
TForm(Owner).OnCanResize := SubclassedParentWndProc;
end;
type
TfORMhack = class(TForm);
procedure TresizeKit.SubclassedParentWndProc(Sender: TObject;
var NewWidth, NewHeight: Integer; var Resize: Boolean);
begin
// inherited;
// if assigned(FOldWindowProc) then
// FOldWindowProc(Sender, NewWidth, NewHeight ,Resize) ;
// if Resize and TfORMhack(Owner).visible then
if (NewWidth = TForm(Owner).Width) and (NewHeight = TForm(Owner).Height) or
// (TForm(Owner).Align = alNone) OR
(TForm(Owner).Height = 240) // 1 и 2 вызовы
then
Exit;
if NewHeight / TfORMhack(Owner).Height > NewWidth / TfORMhack(Owner).Width then
TfORMhack(Owner).ScaleControls(NewWidth, TForm(Owner).Width)
else
TfORMhack(Owner).ScaleControls(NewHeight, TForm(Owner).Height);
end;
procedure Register;
begin
RegisterComponents('resizeKit ', [TresizeKit]);
end;
end.