我正在GUI应用程序中左右移动TMemo
对象。问题是,一旦移动开始,我TMemo
中的字母就会闪烁。
我看了这个,显然,设置我主表单的DoubleBuffering
属性应该对我有帮助,但事实并非如此。所以我尝试在所有正在移动的对象上将该属性设置为true,但仍然存在闪烁。
有没有办法在Lazarus中实现GUI组件的无闪烁动画?我是Lazarus的新手,所以我现在正在盲目地搜索解决方案。我真的很感激一些帮助。
为了提供更多背景信息,以下是我为TMemo
设置动画的方法:我的TTimer
的间隔值为10,其OnTimer
事件会移动TMemo
左右连续。为了使运动稍微平滑,我添加了一个简单的余弦插值函数。
最后这里是代码:
procedure TServerSideForm.ControlPanelHideTimerTimer(Sender: TObject);
begin
if (hideAnimVal < 1) then
begin
hideAnimVal := hideAnimVal + 0.025;
end
else
begin
MemoHideTimer.Enabled:=false;
end;
// hideStart - starting position of my TMemo, hideEnd - end position of my TMemo
hideCurr := Round(CosineInterpolation(hideStart, hideEnd, hideAnimVal));
Memo.Left:=hideCurr;
end;
余弦插值:
function CosineInterpolation(Val1, Val2, Angle: Double): Double;
var
Percent: Double;
begin
Percent := (1-Cos(Angle*PI))/2;
Result := (Val1 * (1 - Percent) + Val2 * Percent);
end;
答案 0 :(得分:0)
我会尝试移动图片:
#include <Windows.h>
typedef struct IPortableDeviceManager IPortableDeviceManager;
HRESULT createPortableDeviceManager(IPortableDeviceManager **pPortableDeviceManager);