I have a “caution” image on a dialog that is shown if there are questionable parameter values. Users do not always notice it, so I want to fade it in and out cyclically over a second or so (yes, I could just toggle the Visible property, but that would look a bit like I was just toggling the Visible property). Is there a simpler way than putting it on it’s own form and floating it over the dialog (and changing the AlphaBlendValue property of the form)?
Share
You can do this using the
Opacityparameter ofTCanvas.Draw. Behind the scenes this callsTGraphic.DrawTransparentwhich in turn calls the WindowsAlphaBlendAPI function. An easy way to implement this is with aTPaintBox:If you are using an older version of Delphi without the
Opacityparameter ofTCanvas.Drawyou can useAlphaBlenddirectly.Thanks to Giel for suggesting the
Opacityparameter ofTCanvas.Draw, and for Sertac for pointing out that it is quite a recent addition toTCanvas.Draw.