Not realy related but I see lots of code like:
if Stayontop.Checked = true
This is a rather redundant style of coding.
There is no need to compare the value of a boolean against true or false.
Just a simple if Stayontop.Checked is enough.
If it would not be enough then there would be no end to it, since (Stayontop.Checked = true) itself is a boolean, and by your programming logic it should be compared to either true or false, and so on.
if ((((Stayontop.Checked = true)=true)=true)=true)=true) ... ad infinitum
Further more:
procedure TForm1.StayontopClick(Sender: TObject);
begin
if Stayontop.Checked = false
then
begin
Stayontop.Checked:=true;
FormStyle:=fsStayOnTop;
end
else
if Stayontop.Checked = true
then
begin
Stayontop.Checked:=false;
FormStyle:= fsNormal;
end;
end;
Why the "if Stayontop.Checked = true" after the else, what other value could it possibly have, since you already know that it is not false.
AFAIK booleans don't come as true, false or maybe
This accomlishes the same and it reads a lot better:
procedure TForm1.StayontopClick(Sender: TObject);
begin
if not Stayontop.Checked then
FormStyle:=fsStayOnTop;
else
FormStyle:= fsNormal;
Stayontop.Checked:=not Stayontop.Checked;
end;
Bart
yes all I had to do was write it like this -- because an if statement always checks for true
if (StayOnTop.Checked) then
begin
FormStyle:=fsNormal;
StayOnTop.Checked:=false;
end
else
begin
StayOnTop.Checked:=true;
FormStyle:=fsStayOnTop;
end;
the only thing that is going on in this is if true dto this and if not true do that-
where you did backwards logic
if not true to that and if true do this
instead
all I did was add something that didn't need to be there because the IF Statement checks for true already -- adding :=true was just a redundant argument for the IF Statement is all -- my bag
another simple example by check for true first is this: in menu.checked or not check check
procedure TForm1.MIRandomClick(Sender: TObject);
begin
if (MIRandom.Checked) then
MiRandom.Checked:=false
else
MIRandom.Checked:=true;
end;
// where this will give you the same results it just looked funny to you
procedure TForm1.MIRandomClick(Sender: TObject);
begin
if (MIRandom.Checked = true) then
MiRandom.Checked:=false
else
MIRandom.Checked:=true;
end;
regardless of how one writes it. it all stays the same basic yes no, on off logic