Jump to content

Set TUniForm to be the maximum size of the web browser when resized


wsv01

Recommended Posts

I know this has been covered several times, but I cannot seem to get it to work. Basically, I have an application with a menu on the main form. I have set the Server property of MainFormDisplayMode to mfPage. When the app runs, the main menu is perfect. When I resize the browser window it acts as expected. Now I want to create a form and when opened, act exactly like the main form. I've tried to set the WindowState to wsMaximized and when opened, it looks great, but when I resize the browser window, it just remains the same size. I'm new that this so I am most likely missing something very basic or is this harder than I expect? Any help would be greatly appreciated.

Link to comment
Share on other sites

procedure TUniForm.UniFormCreate(Sender: TObject);
begin
  Self.Height:= UniApplication.ScreenHeight -40;
  Self.Width := UniApplication.ScreenWidth -200;

and / or

procedure TUniForm.xxxxxxFormScreenResize(Sender: TObject; AWidth, AHeight: Integer);
begin
  Self.Width := AWidth;
  Self.Height:= AHeight;

maybe helpful to you.

Link to comment
Share on other sites

Freeman35,

Thanks for the code. I tried that and it does resize the screen when opened, but when I resize the browser window, it does not resize the form.

What I am trying to do is to have the window that is opened always be the full size of the browser window.

wilton_rad,

I think the frame idea only works on the main form. I tried frames in forms that I open from the main form and it does not seem to work for me.

I looked at the demo layout - features and that does what I want, but that is all done from the main form. I need that same behavior from a form that is opened form the main form. 

If anyone could create a very simple app that does what I want, that would be great!

 

Link to comment
Share on other sites

  • 2 months later...
On 7/4/2019 at 2:48 PM, wsv01 said:

Freeman35,

Thanks for the code. I tried that and it does resize the screen when opened, but when I resize the browser window, it does not resize the form.

What I am trying to do is to have the window that is opened always be the full size of the browser window.

wilton_rad,

I think the frame idea only works on the main form. I tried frames in forms that I open from the main form and it does not seem to work for me.

I looked at the demo layout - features and that does what I want, but that is all done from the main form. I need that same behavior from a form that is opened form the main form. 

If anyone could create a very simple app that does what I want, that would be great!

 

hi

I actually needed the same today and after many tries I found that what you said "UniFormScreenResize only works on the main form" is true , based on that the solution is to resize the other form from the main form like that

First Set the form WindowState to wsMaximized;

in the main form where the form is created use this

procedure TMainForm.ActionExecute(Sender: TObject);
begin
   Lform := TYourform.Create(UniApplication);
end;

procedure TMainForm.UniFormScreenResize(Sender: TObject; AWidth,
   AHeight: Integer);
begin
   if Assigned(Lform) then
   begin
      Lform.WindowState := wsNormal;      
      Lform.Width := AWidth;
      Lfrom.Height := AHeight;
   end;
end;

Regards

Link to comment
Share on other sites

Thanks so much for the code, however, I'm not following a couple things. I guess I don't know too much on how this goes together.

1. The ActionExecute procedure. Is that a procedure name you made up or is it an event somewhere I cannot find? Do I just create a new procedure called ActionExecute?

2. The Lform object. Where is that coming from?

3. I'm assuming that the TYourform would be replaced by my actual form name. 

The way I open new windows from the main form is simply include them in the uses section, then call something like this to open them up.

MyForm.ShowModal()

Sorry for not understanding, but hopefully you can help me out.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...