shawn857
asked on
My app's form does not show full-screen on computers with higher resolution display
Hi Experts... I developed my D7 app on a relatively old laptop with lower resolution. When I install my app on computers with higher resolution, it doesn't show "full-screen" - and has big gaps to the right and bottom. It looks sloppy! Do you know if there is any Delphi component I can add to my app that will automatically "re-size" my form (and maybe controls too) so everything looks in proportion and is full-screen... no matter what the resolution is on the target computer?
Thanks!
Shawn
Thanks!
Shawn
ASKER
Thank you Subrat, but Anchor property of what... of my Form? I'm unfamiliar with how it works, can you please explain a little more on how I use it?
Thanks!
Shawn
Thanks!
Shawn
Use OnShow event of Form to set:
This will maximize form to full except taskbar.
Do you want total "full screen"?
Self.WindowState := wsMaximized;
In design set Position property to poDefault.This will maximize form to full except taskbar.
Do you want total "full screen"?
ASKER
I think I would prefer some ready-made component to handle this... is there a free one (or inexpensive one) out there?
Thanks
Shawn
Thanks
Shawn
there is no component to fix this
when designing a form you need to think about what has to fill-out canvas space and what doesn't
otherwise it will always look "sloppy"
items which typically need to be set with align = alClient
memo, richtedit, grids, etc ...
if you resize all proportionally then it's gonna look "sloppy" too
proportional sizing means this:
a caption and memo
> on the small screen the memo can contain 20 lines
on the big screen it will also contain 20 lines
but the text will be 4 to 6 times bigger.
the feedback i got from the users with proportional
> do you think i have a visual disability ? No ? Really ?
> Then why are all the texts in font-size 40 instead of 10 ?
every component (or most of them) contain an alignment property to solve this
redesign your form with that property set correctly
there isn't any good quick-and-dirty component to do this correctly
when designing a form you need to think about what has to fill-out canvas space and what doesn't
otherwise it will always look "sloppy"
items which typically need to be set with align = alClient
memo, richtedit, grids, etc ...
if you resize all proportionally then it's gonna look "sloppy" too
proportional sizing means this:
a caption and memo
> on the small screen the memo can contain 20 lines
on the big screen it will also contain 20 lines
but the text will be 4 to 6 times bigger.
the feedback i got from the users with proportional
> do you think i have a visual disability ? No ? Really ?
> Then why are all the texts in font-size 40 instead of 10 ?
every component (or most of them) contain an alignment property to solve this
redesign your form with that property set correctly
there isn't any good quick-and-dirty component to do this correctly
the windowstate wsMaximized will fill out your form completely on the screen it's displayed
> with a workaround bugfix: form_instance.top := 0;
on some delphi/windows versions the maximize doesn't put the form at the top
> with a workaround bugfix: form_instance.top := 0;
on some delphi/windows versions the maximize doesn't put the form at the top
To show maximized form is easy - set in design mode properties of form:
Position := poDefault
WindowState := wsMaximized
About form scaling - maybe you can have a luck with Easysize component on Torry.net
Position := poDefault
WindowState := wsMaximized
About form scaling - maybe you can have a luck with Easysize component on Torry.net
ASKER
Geert, you are correct and you've given me something to think about. I've been too concerned with trying to have my app be displayed as "fullscreen" to everybody. I should be focusing more on making it simply look decent to everybody, whether it fills their full screen or not. But still, all this alignment and anchor stuff is confusing to me and I basically don't know where to start.
OK, certainly more info is needed for you guys to help me: My development computer is a fairly old IBM laptop, with 1024x768 resolution and 96 DPI (normal size). And here is a screenshot of my app - basically it is a TPageControl with 3 pages on top of a regular form. When I designed my app, I made the main form and TPageControl basically fill out the full screen. For your information, the pertinent properties of my main form are:
Align = alLeft
Anchors = akLeft, akTop, akBottom
AutoScroll = True
AutoSize = False
FormStyle - fsNormal
Position = poScreenCenter
Scaled = True
WindowState = wsNormal
... and for my TPageControl
Align = alNone
Anchors = akLeft, akTop
Naturally, my form and PageControl are designed to be "wider" than "taller", as I designed it to fit the whole screen of my development computer... and I guess I would just like to keep these same basic proportions (ie. width > height) with any target computer - so it doesn't look too stretched out or "silly". I realize that on a higher resolution computer, there is then going to be some "empty space" at the right and the bottom of the screen... and that's okay, I can live with that - I don't need to have it "fullscreen" on every target computer. As Geert said, to increase font sizes so much that it looks ridiculous just to be "proportional", is not smart. So can anyone offer my some suggestions as to what "align" and "anchor" settings I might need to use to accomplish this?
Thanks!
Shawn
fullscreen.jpg
OK, certainly more info is needed for you guys to help me: My development computer is a fairly old IBM laptop, with 1024x768 resolution and 96 DPI (normal size). And here is a screenshot of my app - basically it is a TPageControl with 3 pages on top of a regular form. When I designed my app, I made the main form and TPageControl basically fill out the full screen. For your information, the pertinent properties of my main form are:
Align = alLeft
Anchors = akLeft, akTop, akBottom
AutoScroll = True
AutoSize = False
FormStyle - fsNormal
Position = poScreenCenter
Scaled = True
WindowState = wsNormal
... and for my TPageControl
Align = alNone
Anchors = akLeft, akTop
Naturally, my form and PageControl are designed to be "wider" than "taller", as I designed it to fit the whole screen of my development computer... and I guess I would just like to keep these same basic proportions (ie. width > height) with any target computer - so it doesn't look too stretched out or "silly". I realize that on a higher resolution computer, there is then going to be some "empty space" at the right and the bottom of the screen... and that's okay, I can live with that - I don't need to have it "fullscreen" on every target computer. As Geert said, to increase font sizes so much that it looks ridiculous just to be "proportional", is not smart. So can anyone offer my some suggestions as to what "align" and "anchor" settings I might need to use to accomplish this?
Thanks!
Shawn
fullscreen.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for the detailed reply Geert... this is a sensible framework I will absolutely follow for any future apps I make. Right now with this one though, I'm behind schedule as it is to get it out to my testers and I just can't undertake major design surgery on my app right now. Basically at this time, I would be satisfied having my app being snuggled up to the top left corner of the target user's screen, while keeping essentially the same size as I designed it , if possible(1024x768). If it doesn't fill the user's whole screen, that doesn't matter... just as long as my original proportions are still approximately okay. Could you give any advice of selections of Align and Anchor properties, or special code in the Form OnCreate event to achieve this?
Thank You!
Shawn
Thank You!
Shawn
forget anchor and align for a form, they don't make sense in that aspect
subrat2009 doesn't seem to be a Delphi connaisseur
if you want it an initial position top, left, set form.position to poDesigned
and in the formcreate set top and left to 0
you could also set the mainform to poScreenCenter so it goes nicely in the middle of the attention ... :)
subrat2009 doesn't seem to be a Delphi connaisseur
if you want it an initial position top, left, set form.position to poDesigned
and in the formcreate set top and left to 0
you could also set the mainform to poScreenCenter so it goes nicely in the middle of the attention ... :)
ASKER
Thanks Geert, I'll try that. Geert, Is it necessary to set any Align or Anchor properties on my TPagecontrol... ?
Thanks
Shawn
Thanks
Shawn
Try to make small test example with some components you use in real app. Play with align/anchor properties as Geert suggest. You will teach something and not mess up real app.
ASKER
Geert, the poDesigned worked good. Geert, I will urge my users to have a minimum screen resolution of 1024x768... but in the event that a user has a very low resolution (for example 800x600), I wrote some code for my Form.OnCreate event in hopes of keeping my form's width/height ratio and proportions "approximately" the same, no matter the resolution on the target computer:
(...Frmindicate is what I named my Form)
Well, when I run this on 800x600 resolution, the form is the proper size, but my controls within the form (TPagecontrol, etc) don't show up completely or are only partially shown. Would "anchoring" or "aligning" My TPagecontrol to my Form do any good?
Thanks
Shawn
OriginalFormHeight := 738;
OriginalFormWidth := 1024;
Frmindicate.Left :=0;
Frmindicate.Top :=0;
if (Screen.Height >= OriginalFormHeight) and (Screen.Width >= OriginalFormWidth) then
begin
Frmindicate.Height := OriginalFormHeight;
Frmindicate.Width := OriginalFormWidth;
end
else if (Screen.Height < OriginalFormHeight) and (Screen.Width >= OriginalFormWidth) then // eg. 1280 x 700
begin
Frmindicate.Height := Screen.Height;
Frmindicate.Width := Round(Screen.Height * (OriginalFormWidth / OriginalFormHeight));
end
else if (Screen.Height >= OriginalFormHeight) and (Screen.Width < OriginalFormWidth) then // eg. 1000 x 824
begin
Frmindicate.Width := Screen.Width;
Frmindicate.Height := Round(Screen.Width * (OriginalFormHeight / OriginalFormWidth));
end
else // both height and Width are smaller than development machine's,
begin
if (Screen.Width/Screen.Height) >= (OriginalFormWidth/OriginalFormHeight) then // eg. 800 x 580
begin
Frmindicate.Height := Screen.Height;
Frmindicate.Width := Round(Screen.Height * (OriginalFormWidth / OriginalFormHeight));
end
else // eg. 800x648
begin
Frmindicate.Width := Screen.Width;
Frmindicate.Height := Round(Screen.Width * (OriginalFormHeight / OriginalFormWidth));
end;
end;
(...Frmindicate is what I named my Form)
Well, when I run this on 800x600 resolution, the form is the proper size, but my controls within the form (TPagecontrol, etc) don't show up completely or are only partially shown. Would "anchoring" or "aligning" My TPagecontrol to my Form do any good?
Thanks
Shawn
i assume the missing controls are on the bottom and on the right side ?
anchors is useless in this case
you can set the min max size in the constraints of a control
if you place controls on those side, you need the following
Basic setup:
The top and left panel as usual alTop and alLeft aligned
The data panel filling out the rest of the form with alClient
within that data panel,
you need an extra panel on the bottom or on the right side
> make sure the parent is the data panel
the right panel should be set to align = alRight
the bottom panel should be set to align = alBottom
set the width of the right panel, height of bottom panel
and cut/paste the buttons to that new panel
here is a form sample with everything aligning accordingly
dfm:
anchors is useless in this case
you can set the min max size in the constraints of a control
if you place controls on those side, you need the following
Basic setup:
The top and left panel as usual alTop and alLeft aligned
The data panel filling out the rest of the form with alClient
within that data panel,
you need an extra panel on the bottom or on the right side
> make sure the parent is the data panel
the right panel should be set to align = alRight
the bottom panel should be set to align = alBottom
set the width of the right panel, height of bottom panel
and cut/paste the buttons to that new panel
here is a form sample with everything aligning accordingly
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
pnlLeft: TPanel;
pnlTop: TPanel;
pnlData: TPanel;
Panel4: TPanel;
pnlDataBottom: TPanel;
btnRemoveBorders: TButton;
pnlResults: TPanel;
Label1: TLabel;
Memo1: TMemo;
pnlTopRightButton: TPanel;
btnStayOnTheright: TButton;
Edit1: TEdit;
Label2: TLabel;
Button1: TButton;
procedure btnRemoveBordersClick(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnRemoveBordersClick(Sender: TObject);
var
I: Integer;
begin
for I := 0 to ComponentCount - 1 do
if Components[I] is TPanel then
(Components[I] as TPanel).BevelOuter := bvNone;
end;
end.
dfm:
object Form1: TForm1
Left = 103
Top = 157
Caption = 'Form1'
ClientHeight = 312
ClientWidth = 684
Color = clBtnFace
Constraints.MinHeight = 350
Constraints.MinWidth = 700
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object pnlLeft: TPanel
Left = 0
Top = 41
Width = 81
Height = 271
Align = alLeft
Caption = 'Panel Left'
TabOrder = 0
end
object pnlTop: TPanel
Left = 0
Top = 0
Width = 684
Height = 41
Align = alTop
TabOrder = 1
DesignSize = (
684
41)
object Label2: TLabel
Left = 224
Top = 16
Width = 196
Height = 13
Caption = 'Right side of edit grows with right border'
end
object btnRemoveBorders: TButton
Left = 16
Top = 8
Width = 121
Height = 25
Caption = 'btnRemoveBorders'
TabOrder = 0
OnClick = btnRemoveBordersClick
end
object pnlTopRightButton: TPanel
Left = 545
Top = 1
Width = 138
Height = 39
Align = alRight
TabOrder = 1
object btnStayOnTheright: TButton
Left = 8
Top = 9
Width = 121
Height = 25
Caption = 'Stay on the right'
TabOrder = 0
end
end
object Edit1: TEdit
Left = 426
Top = 10
Width = 106
Height = 21
Anchors = [akLeft, akTop, akRight]
TabOrder = 2
Text = 'Edit1'
end
end
object pnlData: TPanel
Left = 81
Top = 41
Width = 603
Height = 271
Align = alClient
Caption = 'Panel DATA'
TabOrder = 2
ExplicitLeft = 87
ExplicitTop = 65
ExplicitWidth = 882
ExplicitHeight = 460
object Panel4: TPanel
Left = 481
Top = 1
Width = 121
Height = 210
Align = alRight
Caption = 'Panel Data Right'
TabOrder = 0
DesignSize = (
121
210)
object Button1: TButton
Left = 16
Top = 179
Width = 94
Height = 25
Anchors = [akRight, akBottom]
Caption = 'Bottom Right'
TabOrder = 0
end
end
object pnlDataBottom: TPanel
Left = 1
Top = 211
Width = 601
Height = 59
Align = alBottom
Caption = 'Panel Data Bottom'
TabOrder = 1
end
object pnlResults: TPanel
Left = 1
Top = 1
Width = 480
Height = 210
Align = alClient
Caption = 'Panel Results'
TabOrder = 2
ExplicitLeft = 248
ExplicitTop = 120
ExplicitWidth = 385
ExplicitHeight = 233
object Label1: TLabel
Left = 1
Top = 1
Width = 478
Height = 13
Align = alTop
Caption = 'Results :'
ExplicitWidth = 42
end
object Memo1: TMemo
Left = 1
Top = 14
Width = 478
Height = 195
Align = alClient
Constraints.MinHeight = 195
Constraints.MinWidth = 470
Lines.Strings = (
'Memo1')
TabOrder = 0
ExplicitLeft = 5
ExplicitTop = 9
ExplicitWidth = 757
ExplicitHeight = 408
end
end
end
end
Use Anchor property on all of the components on the form. 5 minutes work. No big deal ....
ASKER
Senad - anchor set to what? Top? Left?, etc?
Thanks
Shawn
Thanks
Shawn
http://www.youtube.com/watch?v=FNWcy8S2k4Y
if its on the right (the component) then turn off akLeft,akTop (False) and set other 2 to True.So no matter how the form resizes components stay in place. Resolution has nothing to do with it.
if its on the right (the component) then turn off akLeft,akTop (False) and set other 2 to True.So no matter how the form resizes components stay in place. Resolution has nothing to do with it.
ASKER
Thank you Geert!
Cheers
Shawn
Cheers
Shawn
FYI;I don't hav Emabarcadero installed in my PC.