In my map form I have the below procedures.
In order to try to solve another bug, I added a counter to the form and an inc(counter) to the beginning of the DrawHeadings procedure.
When I run my app, default checked is largemap and squares.
If I click HeadingsRadio, then shut the form (called by my main form) the counter is 7.
If I activate the form again, and de-activate, the counter is incremented by 12, every time.
Why is the DrawHeadings procedure being called so many times?
Steve (Delphi 2007 & XP)
In order to try to solve another bug, I added a counter to the form and an inc(counter) to the beginning of the DrawHeadings procedure.
When I run my app, default checked is largemap and squares.
If I click HeadingsRadio, then shut the form (called by my main form) the counter is 7.
If I activate the form again, and de-activate, the counter is incremented by 12, every time.
Why is the DrawHeadings procedure being called so many times?
Code:
procedure TMapForm.FormCreate(Sender: TObject);
begin
counter := 0;
end;
procedure TMapForm.FormDeactivate(Sender: TObject);
begin
showmessage(inttostr(counter));
end;
procedure TMapForm.FormDestroy(Sender: TObject);
begin
BMPbackground.Free;
end;
procedure TMapForm.FormPaint(Sender: TObject);
begin
Canvas.Draw( 0, 32, BMPbackground ); // 32 pixels down for the top panel
if SquaresRadio.Checked then DrawSquares else Drawheadings;
end;
procedure TMapForm.FormShow(Sender: TObject);
begin
if LargeMapRadio.Checked then LoadLargeMap else LoadSmallMap;
end;
procedure TMapForm.HeadingsRadioClick(Sender: TObject);
begin
DrawHeadings;
end;
procedure TMapForm.SquaresRadioClick(Sender: TObject);
begin
DrawSquares;
end;
procedure TMapForm.SmallMapRadioClick(Sender: TObject);
begin
LoadSmallMap;
end;
procedure TMapForm.LargeMapRadioClick(Sender: TObject);
begin
LoadLargeMap;
end;
procedure TMapForm.LoadSmallMap;
begin
// small map loading stuff cut out for space saving
if SquaresRadio.Checked then DrawSquares else Drawheadings;
end;
procedure TMapForm.LoadLargeMap;
begin
// large map loading stuff cut out for space saving
if SquaresRadio.Checked then DrawSquares else Drawheadings;
end;
Steve (Delphi 2007 & XP)