Jump to content

How to make Horizontal Center Form using Code.


AMIT

Recommended Posts

I create a test WebApplication and Set MainFormDisplayMode to mfWindow. I also set the position property of the MainForm to poDesktopCenter in order to make my MainForm Display in the center. If the browser windows size is bigger than my MainForm, every thing is look perfect. If the browser windows size is smaller than my MainForm, the top part of my MainForm is hidden because it lay outside the browser windows area. The problem is I can not drag my MainForm back to the browser window. Even there is a vertical scrollbar but the slider of the scrollbar is at the top already. So is it possible to have the MainForm displayed at the horizontal center only. Hope somebody can help, Thank in advance.

Link to comment
Share on other sites

Set MainForm->MonitorScreenResize->True

 

In MainForm OnScreenResize event recalculate Form Left, Top, Width and Height so it will fit and show in desired position.

 

I think it is better to let you have the picture of the output that I have so you can understand my problem easily. Please see the pictures attached.

post-199-0-77494700-1310603663_thumb.jpg

post-199-0-07549300-1310603679_thumb.jpg

post-199-0-51144100-1310603713_thumb.jpg

post-199-0-22293500-1310603731_thumb.jpg

post-199-0-50112000-1310603749_thumb.jpg

Link to comment
Share on other sites

  • Administrators

There is no way to enable the scroll bars when Form top has a negative coordinate. There is no solution for this. It is either an Ext JS or a DOM limitation I'm not sure which one.

 

So you must either adjust the coordinates yourself in OnScreenResize event or design your Form as maximized so Top bar will be always visible.

 

 

 


TMainForm->MonitorScreenResize->True

procedure TMainForm.UniFormScreenResize(Sender: TObject; AWidth,  AHeight: Integer);
begin
 if AHeight<Self.Height then
 begin
Top:=1;
Left:=1;
 end;
end;

 

In mfPage mode you must set AutoScroll->True to see the Scroll bars.

 

I think best way is using mfPage mode + AutoScroll->True.

Link to comment
Share on other sites

Hi,

 

I have a question regarding the centralization of my main page.

My purpose is to have the home centered on the user's browser, regardless of the resolution and screen size that is running, as is seen in most sites today, as an example: fifa.com, twitter.com, etc..

Attached below the image as an example, where in a display of 16.4 "appears perfectly, but in a lower resolution, the login panel is distorted to the right side.

 

I tested the properties MonitorScreenResize and Position, but without success. I use MainFormeDisplayMode = mfPage.

 

Tks.

post-17-0-99046000-1310670889_thumb.jpg

Link to comment
Share on other sites

  • Administrators

If you want a screen object (a UniPanel for instance) to always remain in center of its parent just make it "Anchorless"

 

Anchors -> [ ]

 

In your markbook site I can see that you have a main panel (with rounded corners). Remove all of its Anchors and it will remain in center of screen regardless of screen resolution.

 

BTW, cool site. Couldn't notice that it is an Ext JS / uniGUI site.

Link to comment
Share on other sites

If you want a screen object (a UniPanel for instance) to always remain in center of its parent just make it "Anchorless"

 

Anchors -> [ ]

 

In your markbook site I can see that you have a main panel (with rounded corners). Remove all of its Anchors and it will remain in center of screen regardless of screen resolution.

 

BTW, cool site. Couldn't notice that it is an Ext JS / uniGUI site.

 

Thanks Farshad!

I managed with Anchors .. Only the main page after login, where I have a panel to the top and some panels in the center and another panel at the bottom, I had some work to achieve the desired effects .. but it worked!

Tks for the comment of the site .. Yes, it is UniGui(fantastic) with Delphi!! I'm also using DataSnap to the business classes and to encapsulate the database access.

 

Best Regards..

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...