问题
My program is doing a time consuming task, and I would like to display a TImage in the middle of the application window, but it will not stay on top - my VST is always on top. However, when I use a TPanel, it stays on top? How can I make my TImage do that?
In fact, a solution that applies to all controls would be splendid :)
Thanks!
回答1:
You need a windowed control (that is, a control with a window handle, or a "proper" control) to display your message, because a non-windowed control cannot be visible above a windowed control. The easiest solution is to place the TImage
in a TPanel
and set Image1.Align := alClient
and Panel1.BorderStyle := bsNone
.
If you wish to draw a semi-transparent bitmap on top of your ordinary controls, you can do like I always do:
procedure TForm1.Button1Click(Sender: TObject);
var
bm: TBitmap;
png: TPngImage;
begin
// The form contains a hidden TPanel (somewhere on the form)
// with a TImage (alClient).
// png is a PNG image with an alpha channel
png := TPngImage.Create;
try
png.LoadFromFile('C:\Users\Andreas Rejbrand\Pictures\alpha.png');
// Create bitmap of form and blend PNG on it
bm := GetFormImage;
try
bm.Canvas.Draw(0, 0, png);
Image1.Picture.Bitmap := bm;
finally
bm.Free;
end;
Panel1.Align := alClient;
Panel1.BringToFront;
Panel1.Show;
finally
png.Free;
end;
end;
回答2:
A TImage does not have a window associated with it and that's the difference between it and the panel.
Add a panel, and put the image inside the panel, i.e. the image's parent is the panel. Then you can bring the image to the front by bringing the panel to the front.
Did you think about hiding your VST?
来源:https://stackoverflow.com/questions/5369681/controls-on-top-like-tpanel-can-do