I needed to run the code not in OnShow event, but after the form had made visible to the user. I found this trick
procedure TfrmIncorrectPaths.FormShow(Sender: TObject);
lblCount.Caption := '';
lblMatches.Caption := '';
tmr1.Enabled := True;
procedure TfrmIncorrectPaths.tmr1Timer(Sender: TObject);
if Counter < 2 then
tmr1.Enabled := False;
PostMessage(Self.Handle, WM_AFTER_SHOW, 0, 0);
procedure TfrmIncorrectPaths.WmAfterShow(var Msg: TMessage);
//here the loop
The timer is a my addition in order to grant all controls were drawn on the form.
The problem arises in the loop I place in WmAfterShow event. Please, take a look at this question: www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_28414283.html
. There you find all details and a solution. The problem is that the solution doesn't work in the WmAfterShow event: it seems like the call to Progress.StepProgress were made again and again: I really don't understand.
The most surprising thing is that if I don't call ProgressBar.StepProgress(1
) from the main program, the ProgressBar fills up almost to half bar and thn stops, but it should simply do nothing!!!