OmniThread:如何在SetParameter中传递TRect? [英] OmniThread: How to pass a TRect in SetParameter?

查看:140
本文介绍了OmniThread:如何在SetParameter中传递TRect?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用OmniThread库的程序中,如何在SetParameter中传递TRect?示例:

In a program using the OmniThread library, how can I pass a TRect in SetParameter? Example:

procedure TestParameters(const ATask: IOmniTask);
begin
  // how can I access the TRect here?
end;

FTestTask := CreateTask(TestParameters, 'TestParameters')
               .MonitorWith(OTLMonitor)
               .SetParameter('FormRect', Self.ClientRect) // does not work
               .Run;

是否存在通用规则,如何在SetParameter中使用不同类型?

Is there a general rule how to use different types in SetParameter?

推荐答案

使用TOmniValue.FromRecord<T>TOmniValue.ToRecord<T>.

procedure TestParameters(const ATask: IOmniTask);
var
  formRect: TRect;
begin
  formRect := ATask.Param['FormRect'].ToRecord<TRect>;
end;

FTestTask := CreateTask(TestParameters, 'TestParameters')
               .MonitorWith(OTLMonitor)
               .SetParameter('FormRect', TOmniValue.FromRecord<TRect>(ClientRect))
               .Run;

这篇关于OmniThread:如何在SetParameter中传递TRect?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆