Form not displaying correctly on Laptop
Moderator: 2ffat
Form not displaying correctly on Laptop
I have a Application that will not fully display on a laptop with a smaller screen.
Can someone please explain what I have done wrong when writing this application, Here are some screen shots showing the problem.
Ray.
Can someone please explain what I have done wrong when writing this application, Here are some screen shots showing the problem.
Ray.
Re: Form not displaying correctly on Laptop
Aspect ratio of the screens. The screens are probably different resolutions.
-----------------------------
Scott
Scott
Re: Form not displaying correctly on Laptop
Thank you.Aspect ratio of the screens. The screens are probably different resolutions.
What can I do to make the form adjust for the differences on create or draw.
Ray.
Re: Form not displaying correctly on Laptop
I had this problem once myself, the only option you have is to make your form smaller
if you have a laptop with an unusual resolution....as far as i know.
if you have a laptop with an unusual resolution....as far as i know.
Re: Form not displaying correctly on Laptop
I will search my archives. It seems to me that there was an article on how to create a form that would change it's size. It may take me awhile as I have a long week's worth of work but only a short week's worth of time to do it.
James P. Cottingham
Look at me still talking
when there is science to do.
Look at me still talking
when there is science to do.
Re: Form not displaying correctly on Laptop
I have found this code for Delphi. I have tried unsuccessfully to convert it to C++Builder. Can someone please help do this.
Ray.
**************************************************************************
Technical Information Database
TI944D.txt Form display with different screen resolutions.
Category :VCL
Platform :All
Product :Delphi All
Description:
When designing forms, it is sometimes helpful to write the code
so that the screen and all of its objects are displayed at the
same size no matter what the screen resolution is. Here is
some code to show how that is done:
Ray.
**************************************************************************
Technical Information Database
TI944D.txt Form display with different screen resolutions.
Category :VCL
Platform :All
Product :Delphi All
Description:
When designing forms, it is sometimes helpful to write the code
so that the screen and all of its objects are displayed at the
same size no matter what the screen resolution is. Here is
some code to show how that is done:
Code: Select all
implementation
const
ScreenWidth: LongInt = 800; {I designed my form in 800x600 mode.}
ScreenHeight: LongInt = 600;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
scaled := true;
if (screen.width <> ScreenWidth) then
begin
height := longint(height) * longint(screen.height) div ScreenHeight;
width := longint(width) * longint(screen.width) div ScreenWidth;
scaleBy(screen.width, ScreenWidth);
end;
end;
Then, you will want to have something that checks to see that
the font sizes are OK. You can iterate over each child
control's font to adjust its size as necessary. This can be
done as follows:
type
TFooClass = class(TControl); { needed to get at protected }
{ font property }
var
i: integer;
begin
for i := ControlCount - 1 downto 0 do
TFooClass(Controls[i]).Font.Size :=
(NewFormWidth div OldFormWidth) *
TFooClass(Controls[i]).Font.Size;
end;
Re: Form not displaying correctly on Laptop
I tried this component and it works well. I do not know if it will work
the way you want it to but it seems as it would. Just follow the
instructions once you have made it into a package for install to
your tool palette. If your form is sizeable with the mouse it should
do what you need it to.
https://github.com/pgiacomo69/TFormResizer
the way you want it to but it seems as it would. Just follow the
instructions once you have made it into a package for install to
your tool palette. If your form is sizeable with the mouse it should
do what you need it to.
https://github.com/pgiacomo69/TFormResizer
Re: Form not displaying correctly on Laptop
Thank you. The problem is it is another Delphi code example. It seams no one uses C++Builder. I do not use Delphi and do not understand the code.
Ray.
Ray.
Re: Form not displaying correctly on Laptop
You make a new package in c++ and add the pas to it and install it as a item in your tool palette.
Re: Form not displaying correctly on Laptop
Plenty of people use C++Builder. It is just more common to see examples and components written in Pascal because C++Builder includes a Delphi compiler, so code can be written one time in Pascal and used in both Delphi and C++Builder projects without needing to be translated.
Remy Lebeau (TeamB)
Lebeau Software
Lebeau Software
Re: Form not displaying correctly on Laptop
Try this:
Code: Select all
const int ScreenWidth = 800; /* I designed my form in 800x600 mode.*/
const int ScreenHeight = 600;
#pragma resource "*.DFM"
// better: use the constructor's actual constructor instead...
// __fastcall TForm1::TForm1(TComponent Owner) : TForm(Owner)
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Scaled = true;
if (Screen->Width != ScreenWidth)
{
Height = Height * Screen->Height / ScreenHeight;
Width = Width * Screen->Width / ScreenWidth;
ScaleBy(Screen->Width, ScreenWidth);
}
}
Code: Select all
class TFooClass : public TControl /* needed to get at protected Font property */
{
public:
__property Font;
};
for(int i = ControlCount - 1; i >= 0; --i) {
((TFooClass*)(Controls[i]))->Font->Size = (NewFormWidth / OldFormWidth) * ((TFooClass*)(Controls[i]))->Font->Size;
}
Remy Lebeau (TeamB)
Lebeau Software
Lebeau Software