Posted by Marc MI'm new to Delphi (1 week) and I must say it is great!
I created an app that needs to change a label color and a shape color when a buton is pressed. Below is the code. Is this the coreect way to do it. It seems convoluted that I have to use labels to associate everything. Thanks for the advice!
Answer by Eric
Your code is correct, you can't simplify it if you want to change properties of several components, each with their own button, but still using a common onclick-event-handler.
Of course, the code becomes much simpler if you have 1 button per label/shape pair:
procedure TForm1.Button1Click(Sender: TObject); begin if Label1.Font.Color = clBlack then Label1.Font.Color := clRed else Label1.Font.Color := clBlack; Shape1.Visible := not Shape1.Visible; end;