Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

form content resize/placement vs screen resolution

HI
have an application form developed for medium hi screen resolution (I use 1280x1024). Now some users are appearing on low res (800x600). Here the form expands out the desktop. Have made small code block invoked in Form.FormCreate

...
with Screen do // adjust for low res screens
begin
if (Height<1024) or (Width<1280) then // down scale form
begin
NewH:=round(Form.Height*Height/1024);
NewW:=round(Form.Width*Width/1280);
ALeft := (Width - NewW) div 2;
ATop := (Height - NewH) div 2;
Form.SetBounds(ALeft, ATop, NewW, NewH);
//how to get all other objects resized/moved also??
end;
end
...
works ok on the main form BUT my objects don't resize/position proportionally (to main form resize) inside main form, so my objects appear outside the main form (i.e. not visible/accesible)

is there a simple way to make the whole form content resize/place objects proportionally to main form resize?

thanks

patrick

Comments

  • zibadianzibadian Member Posts: 6,349
    : HI
    : have an application form developed for medium hi screen resolution (I use 1280x1024). Now some users are appearing on low res (800x600). Here the form expands out the desktop. Have made small code block invoked in Form.FormCreate
    :
    : ...
    : with Screen do // adjust for low res screens
    : begin
    : if (Height<1024) or (Width<1280) then // down scale form
    : begin
    : NewH:=round(Form.Height*Height/1024);
    : NewW:=round(Form.Width*Width/1280);
    : ALeft := (Width - NewW) div 2;
    : ATop := (Height - NewH) div 2;
    : Form.SetBounds(ALeft, ATop, NewW, NewH);
    : //how to get all other objects resized/moved also??
    : end;
    : end
    : ...
    : works ok on the main form BUT my objects don't resize/position proportionally (to main form resize) inside main form, so my objects appear outside the main form (i.e. not visible/accesible)
    :
    : is there a simple way to make the whole form content resize/place objects proportionally to main form resize?
    :
    : thanks
    :
    : patrick
    :
    You can use the Anchors property for to resize the controls. Placing the controls needs to perform the calculations based on the width and height.
    Another approach is to design your form for a res. of 640x480. Then all the important controls will always fall within the maximized form. You can then just use the Anchors to resize controls like TEdits and TMemos.
  • wolf_skatewolf_skate Member Posts: 12
    : : HI
    : : have an application form developed for medium hi screen resolution (I use 1280x1024). Now some users are appearing on low res (800x600). Here the form expands out the desktop. Have made small code block invoked in Form.FormCreate
    : :
    : : ...
    : : with Screen do // adjust for low res screens
    : : begin
    : : if (Height<1024) or (Width<1280) then // down scale form
    : : begin
    : : NewH:=round(Form.Height*Height/1024);
    : : NewW:=round(Form.Width*Width/1280);
    : : ALeft := (Width - NewW) div 2;
    : : ATop := (Height - NewH) div 2;
    : : Form.SetBounds(ALeft, ATop, NewW, NewH);
    : : //how to get all other objects resized/moved also??
    : : end;
    : : end
    : : ...
    : : works ok on the main form BUT my objects don't resize/position proportionally (to main form resize) inside main form, so my objects appear outside the main form (i.e. not visible/accesible)
    : :
    : : is there a simple way to make the whole form content resize/place objects proportionally to main form resize?
    : :
    : : thanks
    : :
    : : patrick
    : :
    : You can use the Anchors property for to resize the controls. Placing the controls needs to perform the calculations based on the width and height.
    : Another approach is to design your form for a res. of 640x480. Then all the important controls will always fall within the maximized form. You can then just use the Anchors to resize controls like TEdits and TMemos.
    :

    thanks
    I didn't something else for now - as relative reposition in runtime of all componens seemed big work doing form scratch. Made a startup change in EasySize component I'm using for resizing. WOrks ok with respect to screen resolution resizing on Intialize form - APART form :

    my form has a width > 1024,
    when starting it up on a low screen resolution the content is truncated on left side proportionally to the extent the form original size > screen size. The actual form being displayed has relative same size on all screen resolutiona and the controls in side apaer with relative size/placements ok (apart form the truncation problem).

    So is there a maxsize limit being invoked some where or how do I get around it

    patrick

  • zibadianzibadian Member Posts: 6,349
    : : : HI
    : : : have an application form developed for medium hi screen resolution (I use 1280x1024). Now some users are appearing on low res (800x600). Here the form expands out the desktop. Have made small code block invoked in Form.FormCreate
    : : :
    : : : ...
    : : : with Screen do // adjust for low res screens
    : : : begin
    : : : if (Height<1024) or (Width<1280) then // down scale form
    : : : begin
    : : : NewH:=round(Form.Height*Height/1024);
    : : : NewW:=round(Form.Width*Width/1280);
    : : : ALeft := (Width - NewW) div 2;
    : : : ATop := (Height - NewH) div 2;
    : : : Form.SetBounds(ALeft, ATop, NewW, NewH);
    : : : //how to get all other objects resized/moved also??
    : : : end;
    : : : end
    : : : ...
    : : : works ok on the main form BUT my objects don't resize/position proportionally (to main form resize) inside main form, so my objects appear outside the main form (i.e. not visible/accesible)
    : : :
    : : : is there a simple way to make the whole form content resize/place objects proportionally to main form resize?
    : : :
    : : : thanks
    : : :
    : : : patrick
    : : :
    : : You can use the Anchors property for to resize the controls. Placing the controls needs to perform the calculations based on the width and height.
    : : Another approach is to design your form for a res. of 640x480. Then all the important controls will always fall within the maximized form. You can then just use the Anchors to resize controls like TEdits and TMemos.
    : :
    :
    : thanks
    : I didn't something else for now - as relative reposition in runtime of all componens seemed big work doing form scratch. Made a startup change in EasySize component I'm using for resizing. WOrks ok with respect to screen resolution resizing on Intialize form - APART form :
    :
    : my form has a width > 1024,
    : when starting it up on a low screen resolution the content is truncated on left side proportionally to the extent the form original size > screen size. The actual form being displayed has relative same size on all screen resolutiona and the controls in side apaer with relative size/placements ok (apart form the truncation problem).
    :
    : So is there a maxsize limit being invoked some where or how do I get around it
    :
    : patrick
    :
    :
    Relative resizing can be done in a very quick way, if you use the inheritance of the objects correctly. Here is a small code to get you started:
    [code]
    for i := 0 to ComponentCount-1 do
    if Components[i] is TControl then
    with TControl(Components[i]) do
    begin
    Left := (Left*Screen.Width) div 1280;
    Width := (Width*Screen.Width) div 1280;
    end;
    [/code]
    This should reposition and resize all your controls in the horizontal axis. I haven't tested it, so it might produce some weird form-layout. But that should be not too difficult to fix.
  • wolf_skatewolf_skate Member Posts: 12
    : : : : HI
    : : : : have an application form developed for medium hi screen resolution (I use 1280x1024). Now some users are appearing on low res (800x600). Here the form expands out the desktop. Have made small code block invoked in Form.FormCreate
    : : : :
    : : : : ...
    : : : : with Screen do // adjust for low res screens
    : : : : begin
    : : : : if (Height<1024) or (Width<1280) then // down scale form
    : : : : begin
    : : : : NewH:=round(Form.Height*Height/1024);
    : : : : NewW:=round(Form.Width*Width/1280);
    : : : : ALeft := (Width - NewW) div 2;
    : : : : ATop := (Height - NewH) div 2;
    : : : : Form.SetBounds(ALeft, ATop, NewW, NewH);
    : : : : //how to get all other objects resized/moved also??
    : : : : end;
    : : : : end
    : : : : ...
    : : : : works ok on the main form BUT my objects don't resize/position proportionally (to main form resize) inside main form, so my objects appear outside the main form (i.e. not visible/accesible)
    : : : :
    : : : : is there a simple way to make the whole form content resize/place objects proportionally to main form resize?
    : : : :
    : : : : thanks
    : : : :
    : : : : patrick
    : : : :
    : : : You can use the Anchors property for to resize the controls. Placing the controls needs to perform the calculations based on the width and height.
    : : : Another approach is to design your form for a res. of 640x480. Then all the important controls will always fall within the maximized form. You can then just use the Anchors to resize controls like TEdits and TMemos.
    : : :
    : :
    : : thanks
    : : I didn't something else for now - as relative reposition in runtime of all componens seemed big work doing form scratch. Made a startup change in EasySize component I'm using for resizing. WOrks ok with respect to screen resolution resizing on Intialize form - APART form :
    : :
    : : my form has a width > 1024,
    : : when starting it up on a low screen resolution the content is truncated on left side proportionally to the extent the form original size > screen size. The actual form being displayed has relative same size on all screen resolutiona and the controls in side apaer with relative size/placements ok (apart form the truncation problem).
    : :
    : : So is there a maxsize limit being invoked some where or how do I get around it
    : :
    : : patrick
    : :
    : :
    : Relative resizing can be done in a very quick way, if you use the inheritance of the objects correctly. Here is a small code to get you started:
    : [code]
    : for i := 0 to ComponentCount-1 do
    : if Components[i] is TControl then
    : with TControl(Components[i]) do
    : begin
    : Left := (Left*Screen.Width) div 1280;
    : Width := (Width*Screen.Width) div 1280;
    : end;
    : [/code]
    : This should reposition and resize all your controls in the horizontal axis. I haven't tested it, so it might produce some weird form-layout. But that should be not too difficult to fix.
    :

    yes this is in principle what the EasySize component (http://delphi.icm.edu.pl/authors/a0001025.htm) is doing and it works perfectly well when the form size < screen resolution. But as soon the form size > screen resolution the form gets truncated before I can do any manipulation on width or height (doing the manupulation just resize the truncated form). SO how do I get get rid of the truncation to start with?. The EasySIze is invoked on FormCreate - the form truncation must happen before that some where.
  • zibadianzibadian Member Posts: 6,349
    : : : : : HI
    : : : : : have an application form developed for medium hi screen resolution (I use 1280x1024). Now some users are appearing on low res (800x600). Here the form expands out the desktop. Have made small code block invoked in Form.FormCreate
    : : : : :
    : : : : : ...
    : : : : : with Screen do // adjust for low res screens
    : : : : : begin
    : : : : : if (Height<1024) or (Width<1280) then // down scale form
    : : : : : begin
    : : : : : NewH:=round(Form.Height*Height/1024);
    : : : : : NewW:=round(Form.Width*Width/1280);
    : : : : : ALeft := (Width - NewW) div 2;
    : : : : : ATop := (Height - NewH) div 2;
    : : : : : Form.SetBounds(ALeft, ATop, NewW, NewH);
    : : : : : //how to get all other objects resized/moved also??
    : : : : : end;
    : : : : : end
    : : : : : ...
    : : : : : works ok on the main form BUT my objects don't resize/position proportionally (to main form resize) inside main form, so my objects appear outside the main form (i.e. not visible/accesible)
    : : : : :
    : : : : : is there a simple way to make the whole form content resize/place objects proportionally to main form resize?
    : : : : :
    : : : : : thanks
    : : : : :
    : : : : : patrick
    : : : : :
    : : : : You can use the Anchors property for to resize the controls. Placing the controls needs to perform the calculations based on the width and height.
    : : : : Another approach is to design your form for a res. of 640x480. Then all the important controls will always fall within the maximized form. You can then just use the Anchors to resize controls like TEdits and TMemos.
    : : : :
    : : :
    : : : thanks
    : : : I didn't something else for now - as relative reposition in runtime of all componens seemed big work doing form scratch. Made a startup change in EasySize component I'm using for resizing. WOrks ok with respect to screen resolution resizing on Intialize form - APART form :
    : : :
    : : : my form has a width > 1024,
    : : : when starting it up on a low screen resolution the content is truncated on left side proportionally to the extent the form original size > screen size. The actual form being displayed has relative same size on all screen resolutiona and the controls in side apaer with relative size/placements ok (apart form the truncation problem).
    : : :
    : : : So is there a maxsize limit being invoked some where or how do I get around it
    : : :
    : : : patrick
    : : :
    : : :
    : : Relative resizing can be done in a very quick way, if you use the inheritance of the objects correctly. Here is a small code to get you started:
    : : [code]
    : : for i := 0 to ComponentCount-1 do
    : : if Components[i] is TControl then
    : : with TControl(Components[i]) do
    : : begin
    : : Left := (Left*Screen.Width) div 1280;
    : : Width := (Width*Screen.Width) div 1280;
    : : end;
    : : [/code]
    : : This should reposition and resize all your controls in the horizontal axis. I haven't tested it, so it might produce some weird form-layout. But that should be not too difficult to fix.
    : :
    :
    : yes this is in principle what the EasySize component (http://delphi.icm.edu.pl/authors/a0001025.htm) is doing and it works perfectly well when the form size < screen resolution. But as soon the form size > screen resolution the form gets truncated before I can do any manipulation on width or height (doing the manupulation just resize the truncated form). SO how do I get get rid of the truncation to start with?. The EasySIze is invoked on FormCreate - the form truncation must happen before that some where.
    :
    The EasySize component might do something else before the OnCreate(). The chain of events is as follows:
    - Form.Create
    - Create of all Components on that form
    - OnCreate()
    The EasySize component might perform something(s) in its own Create(). You'll have to check that with the source code or documentation of that component.
    Another way to check if it is the EasySize, is to remove it then run the program on a larger res. This shouldn't produce any truncation, since no code repositions/resizes the components.
    Last option is to set the 'Use debug DCUs' and check in which statement the truncation occurs. This is quite a time consuming method, so I would only use it as a last resort.
    I hope this helps you to track the problem down.
Sign In or Register to comment.