Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-08-2001, 08:05 AM
bark bark is offline
Junior Member
 
Join Date: Jan 2001
Posts: 2
Default How do I stretch the size of Form when screen res increased?

I need my app to be able to stretch the form (including all components)to full screen size say when changing from 640x480 to 800x600 screen res.
Any ideas out there?
Reply With Quote
  #2  
Old 01-08-2001, 11:34 AM
toolman toolman is offline
Junior Member
 
Join Date: Jan 2001
Posts: 3
Default RE: How do I stretch the size of Form when screen res increased?

I've used the following code on the form.create event to center my form on the screen. This may give a little direction as to how to get the form to adjust when resolution changes. I subtracted 200 pixels from the height and width so as not to fill the screen.

var
screen1 : tScreen;
ftop : Variant;
fLeft : Variant;
begin

screen1 := tscreen.create(self);
fmain.height := screen1.height - 200;
fmain.Width := screen1.Width - 200;
ftop := (screen1.Height - fmain.height) / 2;
fleft := (screen1.width - fmain.width) / 2;

screen1.free;
fmain.top := ftop;
fmain.left := fleft;
end;

You will need to determine the proper event to tie that to. It may be easier to set the forms align property to alclient if you want it full screen always. As far as components on the form go, try using the anchors property, this works fairly well if you utilize a panel and the components are children of that panel and not the form, set the anchors on the panel to tie to the form, the components anchors will be based upon the panel. If that's not an option, I'd consider keeping in mind the position of the components when you start, and then adjust based upon the original and new sizes of the form relative to the position of the component. Keeping in mind that the form is nothing more than a rectangle helps to explain that a little more clearly. Hope this helps and I've not confused you further.
Reply With Quote
  #3  
Old 01-09-2001, 02:54 AM
digitiger digitiger is offline
Senior Member
 
Join Date: Jan 2001
Posts: 716
Default RE: RE: How do I stretch the size of Form when screen res increased?

first of all i am not sure what is your requirement

are u concerned with first time sizing of your form on initialization or do you want to ensure that even if inbetween of your application running if a user changes the screen resolution then also your form should continue covering whole of the screen ?

but the answere to both the requirement is quite simple
.

the most simple way is to define the windowstate property of your form in its property pallete as wsmaximized
that is simply free from borland along with vcl

another approach is just as given in first answere
you can declare two variables and store the width,height.left and top position of your form in relation to screen and then assign those value to the forms dimentions thou not one by one as in prior aswere you can use the following code.
procedure tform1.formcreate
var
lft,tp,wdt,hgt : integer

begin
wdt := screen.width or screen.width - 100 //as reqd
hft := screen.height or screen.height - 100 //as reqd
lft := round((screen.width-wdt)/2);
tp := round((screen.height-hgt)/2);

form1.setbounds(lft,tp,wdt,hgt);
end;

additionally if dont want to keep your form maximized but want if to fill say 90% (or whatever) of its area then you can employ a timer and keep on checking then relation between form's size and screen's size and if it changes then you can again call the formcreate procedure thus resizing your form like below-

tform1.timer1timer
var
lft,tp,wdt,hgt : integer
begin
if form1.width <> screen.width-100 //or whatever difference
then

wdt := screen.width or screen.width - 100 //as reqd
hft := screen.height or screen.height - 100 //as reqd
lft := round((screen.width-wdt)/2);
tp := round((screen.height-hgt)/2);

form1.setbounds(lft,tp,wdt,hgt);
end
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:35 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.