Show banner on form

I have a VCL application where I want to show a banner when the app is not focused. This is triggered via the OnActivate and OnDeactivate events.

If I place a TImage on the grid that’s the main part of the UI it works fine, but I’d really like the banner to show on top of all other content. Most of that content is forms hosted on dock panels, which seem to be hiding the image if I place the TImage on the main form.

Using a form as the banner refocuses the application so that seems to be out. Ideas?

Perhaps you might be able to use something from the following request (if old)

Transparent Form / Pass Through Clicks - delphi (delphigroups.info)

Thanks Roger, I’ll take a look to see if it could do what I want without regaining the focus.

Hi David

You could acheive this with a panel container and image on top of it, but parented by the form. I do this in FinalBuilder - when a long running process (such as loading and saving projects) is going. I have a TPanel used to show a status message - sometimes I want it to show for a certain period of time, so have a timer that will close it.

procedure TMainForm.DisplayStatusMessage(const msg: string; const displayTime: Integer);
begin
  StatusPanel.Caption := '[ ' + msg + ' ]';
  StatusPanel.Visible := True;
  StatusPanel.BringToFront;
  StatusPanel.Invalidate;
  Application.ProcessMessages;
  if displayTime > 0 then
  begin
    StatusTimer.Interval := displayTime;
    StatusTimer.Enabled := True;
  end;
end;

procedure TMainForm.HideStatusMessage;
begin
  StatusTimer.Enabled := False;
  StatusPanel.Visible := False;
  FLastProgress := 0;
end;

procedure TMainForm.StatusTimerTimer(Sender: TObject);
begin
  StatusTimer.Enabled := False;
  StatusPanel.Visible := False;
end;

procedure TMainForm.FormResize(Sender: TObject);
begin
  StatusPanel.Left := (Self.Width - StatusPanel.Width) div 2;
end;

HTH.

Thank you. Putting the image control on a TPanel did indeed work as I wanted. Since the panel is hidden as soon as the application is focused, there’s no issue with the Z order if the user clicks a panel it’s partly covering.

1 Like