Examples Delphi

Search for text in all components on a form...
hi mike,
Try something along the lines of......
------------------------------------------
function Tfrm.CheckForBlankText : Boolean ;
var
n : LongInt ;
begin
Result := false ;
for n := 0 to ( ComponentCount - 1 ) do
begin
if ( components[n].ClassType = TEdit ) then // or ( components[n] is
TEdit )
begin
TEdit (components[n]).text = '' then
begin
Result := true ;
Exit ;
end ;
end ;
end ;
End ;
i am currently up/ downgrading from win NT 4.0 -> win 98 and haven't got
delphi installed yet. (just got outlook 2000 running though!) So i have been
unable to check for typo's. But the principles should be correct, any
problems mail me directly and i will send something i have tested in the
IDE.
ComponentCount and Components[..] are properties of forms in delphi, which i
don't think are too widely documented.
Hope this is of interest to you.
cheers,
David
-----Original Message-----
From: Mike Smit [mailto:mike@awesoft.com]
Sent: 23 March 1999 13:26
To: Delphi@Kyler.com
Subject: Search for text in all components on a form...
Hi All.
Does anybody know of a simple way to check that all textbox's on a form
contain something (not empty) instead of using an if statement for every
control.
Thanks in advance...
Regards - Mike
Analyst Programmer
Alphapos
http://www.awesoft.com
RESIZING ALL COMPONENTS ON A FORM
From: Richard Ebbs
To: Israel Nemlich
Originally: Israel Nemlich
Subject: Form resize
Hi Israel
re your query
> I need help on how to resize (automatically)
> and all it's components every time the form
> is resized.
-off the top of my head I think you'd need
something like this:
1) a couple of global variable to keep track
of the 'old' form width and height, eg
var
oldFormWidth, oldFormHeight: Integer;
and some code in the OnResize event handler
for the form like this perhaps:
procedure MyForm.FormResize(Sender: TObject)
var
widthRatio, heightRatio: Double;
compIndex: Integer;
begin
widthRatio := (MyForm.Width / oldFormWidth);
heightRatio := (MyForm.Height / oldFormHeight);
for compIndex := 0 to (ComponentCount - 1) do
begin
Components[compIndex].Width := Round(Components[compIndex].Width * widthRatio);
Components[compIndex].Height := Round(Components[compIndex].Height * heightRatio);
end;
oldFormWidth := MyForm.Width;
oldFormHeight := MyForm.Height;
end;
so that every time the form is resized all
sub-components are resized by the same ratio
in both the X and Y directions...
I haven't tested the code but it shouldn't be
far off...
(although resizing [eg button] text to an an
appropriate size might be a little fiddly..?)
Hope this is useful.
Richard Ebbs