Jump to content

Form resizing (not Main Form)


Daniel Br

Recommended Posts

Hello friends.

Im using Unigui 1.90.0.1530 Trial Edition on Delphi 10.2 Tokio.

I would like to know how to keep the forms with 100% of width and height when I resize the browser.

Im using AlignmentClient and vbox layout. It works perfectly just in the main Form. But if I show another form (form.show or form.showmodal) doesn´t work anymore.

I tried to use onScreenResize Event, but just works in the Main Form too. I could not find anything about this in the Unigui examples.

How can I do it?

Please, could you help me?

 

Thanks.

Link to comment
Share on other sites

On 4/26/2021 at 10:31 PM, Daniel Br said:

Hello friends.

Im using Unigui 1.90.0.1530 Trial Edition on Delphi 10.2 Tokio.

I would like to know how to keep the forms with 100% of width and height when I resize the browser.

Im using AlignmentClient and vbox layout. It works perfectly just in the main Form. But if I show another form (form.show or form.showmodal) doesn´t work anymore.

I tried to use onScreenResize Event, but just works in the Main Form too. I could not find anything about this in the Unigui examples.

How can I do it?

Please, could you help me?

 

Thanks.

Hi, it is not the best solution but I had to do this for only one form in my application, it will be difficult if you have to do this for all other forms :

I have created a LocalResize in the form and then call it on main form screen resize;

procedure TMainForm.UniFormScreenResize(Sender: TObject; AWidth,
   AHeight: Integer);
begin
      if Assigned(LfraHomeDashBoard)  then
         LfraHomeDashBoard.LocalResize(AWidth, AHeight);
end;

  

 

Link to comment
Share on other sites

You can do it like this (code for LoginFrm). Insert here --> LoginFrm.Script

function doOnResizeChange() {
  if (typeof LoginFrm !== 'undefined') {  
    var winWidth = window.innerWidth,
        winHeight = window.innerHeight;
    LoginFrm.window.setPosition(0, 0);
    LoginFrm.window.setSize(winWidth, winHeight);
  }
}

function doOnOrientationChange() { 
 setTimeout(doOnResizeChange, 1000);
}
  
window.addEventListener('orientationchange', doOnOrientationChange);
window.addEventListener('resize', doOnResizeChange);
setTimeout(doOnResizeChange, 10);

 

Link to comment
Share on other sites

Hello, I use this fo resize mainform and Topform

 

procedure SetFormSize (SelForm : TUniForm);
var
ClientWidth,
ClientHeight    : Integer;
begin

SelForm.Left := 0;
SelForm.Top := 0;
//Get Screen Size
ClientWidth := UniSession.UniApplication.ScreenWidth;
ClientHeight := UniSession.UniApplication.ScreenHeight;
//Set Data
SelForm.Width := ClientWidth;
SelForm.Height := ClientHeight;

{if (uniMainModule.AppPlatform <> [upDesktop])
AND (AnsiUpperCase (UniServerModule.SistemSettingsList.Values ['useAndroidPOS']) <> 'TRUE')
then begin
    SelForm.WindowState := wsNormal;
    SelForm.Left := 0;
    SelForm.Top := 0;
    ClientWidth := UniSession.UniApplication.ScreenWidth;
    ClientHeight := UniSession.UniApplication.ScreenHeight;

    if UniSession.FormsList.Count <= 1 then exit;

    if (ClientWidth < FormMinWidth) then
       ClientWidth := TUniForm (UniSession.FormsList [UniSession.FormsList.Count - 1]).Width;
    if (ClientHeight < FormMinHeight) then
       ClientHeight := TUniForm (UniSession.FormsList [UniSession.FormsList.Count - 1]).Height;

    if ClientWidth  < FormMinWidth then
       ClientWidth := FormMinWidth;
    if ClientHeight < FormMinHeight then
       ClientHeight := FormMinHeight;

    if ClientWidth < SelForm.Width then
       ClientWidth := SelForm.Width;
    if ClientHeight < SelForm.Height then
       ClientHeight := SelForm.Height;

    SelForm.Width := ClientWidth;
    SelForm.Height := ClientHeight;

end;

}

SelForm.Repaint;//Set MainForm Size
form_general.Left := 0;
form_general.Top := 0;
form_general.Width := SelForm.Width;
form_general.Height := SelForm.Height;
form_general.Invalidate;

//Set Top form size

TUniForm (UniSession.FormsList [UniSession.FormsList.Count - 1]).Height := SelForm.Height;
TUniForm (UniSession.FormsList [UniSession.FormsList.Count - 1]).Width := SelForm.Width;
TUniForm (UniSession.FormsList [UniSession.FormsList.Count - 1]).Invalidate;


end;

 

 

procedure TForm_General.UniFormAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin

//activate resize forms

if EventName = 'resize' then begin
    SetFormSize (Self);
end;

end;
 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...