S
S
sorry_i_noob2019-06-10 03:42:44
Delphi
sorry_i_noob, 2019-06-10 03:42:44

How in Delphi to make the frame completely overlap the form on which it is located (taking into account the fact that the form can be scrolled)?

Hello. My application has multiple frames. All of them are located on the same form - on the main one. In some frames, the height can be very large, so it should be possible to scroll the form on which such frames are located. I've set the autoscroll flag to true for the main form where all the frames are located. And I wrote the following code - so that the height and width of the frames correspond to the form.

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Unit3;

type
  TForm1 = class(TForm)
    Frame31: TFrame3;
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure SetPosition;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  SetPosition;
end;

procedure TForm1.FormResize(Sender: TObject);
begin
  SetPosition;
end;

procedure TForm1.SetPosition;
begin
  Frame31.Left := 0;
  Frame31.Top := 0;
  Frame31.Width := Form1.Width;
  Frame31.Height := Form1.Height;
end;

end.

Here is the code for one of the frames - nothing out of the ordinary.
unit Unit3;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
  Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TFrame3 = class(TFrame)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

{$R *.dfm}

end.

Apart from the frames on the main form, I have some other elements. And for some reason, if you scroll, the frames are smaller than the form. I took a screenshot, please take a look. Red is a frame. And gray is the shape. Why is the form sticking out from under the frame? How to make it (frame) COMPLETELY cover the form? And if the information does not fit on it, then the form can be scrolled - to see the frame information that does not fit.
5cfda68c62a96640660790.png5cfda693a6165256902833.png5cfda699d45ac601254391.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2019-06-10
@tsklab

First:

Frame31.Left := 0;
  Frame31.Top := 0;
  Frame31.Width := Form1.ClientWidth;
  Frame31.Height := Form1.ClientHeight;

Second: the first is not needed if set to the frame Align = alClient
AND this contradicts
frames, the height can be very large, so it should be possible to scroll the form

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question