如何在 TcustomContol 中使用 Picture.LoadFromFile()
我创建了一个从 TcustomControl 派生的 TSkinPanel,
它有一个 FGraphic:TPicture。
FGraphic 绘制在 TSkinPanel 的画布上,如果从 TObject Inspector 加载图像,则可以正常工作。
但我不会在运行时加载图像“Form1.SkinPanel1.Picture.LoadFromFile('skin.bmp');
I created a TSkinPanel derive from TcustomControl
it has a FGraphic: TPicture.
the FGraphic is drawn on the canvas of the TSkinPanel and works fine if you load and image from the TObject Inspector.
but i doesnt won'k work on loading image on runtime "Form1.SkinPanel1.Picture.LoadFromFile('skin.bmp');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须使用
TPicture.OnChange
事件,例如:You have to use the
TPicture.OnChange
event, eg:如果调用
Picture.LoadFromFile
时没有出现错误,那么它很可能有效,但您的控件根本没有对更改做出反应。首先要做的是处理Picture.OnChange
事件处理程序并执行某些操作:如果您自己进行绘画,则只需调用Invalidate()
(如果您使用的是 Picture)要设置一些其他控件来依次进行绘制,请在 OnChange 中执行适当的Assign()
。If you get no error when you call
Picture.LoadFromFile
then chances are it worked just but your control is simply not reacting to the change. The first thing to do is to handle thePicture.OnChange
event handler and do something: if you do the painting yourself simply callInvalidate()
, if you're using Picture to set up some other control that in turn does the painting, do the appropriateAssign()
fom OnChange.