Scar Divi Float或Double to Int

时间:2013-01-27 19:57:38

标签: int double pascal

Scar Divi Float或Double to Int。我如何将Float / Double传递给整数?

这是代码。我正在尝试查找位图并单击中心,问题是当我尝试将x或y分开以找到img中心时。

program FindBitmap;

label
main;

var
Bmp: TSCARBitmap;
x, y: Integer;
temp1, temp2: String;

begin
 ClearDebug;
 Bmp := TSCARBitmap.Create('deNqtzGkKglAUhuE2Ea2pwXm8atpAFCIVRdEKi' +
    'qJCkBBpAeVQa+zCBRGH++cEz6/Dd95Oq92ajoZwE8eCG9sm3GhowDkWgrNNHc4' +
    'yNDgTqbnz6fjNMrr49XIXs+IXZuhK0fVyphSS99tz56UXDGlyEb7491ttIY3jp' +
    'eeW9oSuSCVIlQPfLxWyJFkvveqY0GSxCnceQZAXPmm6Xa9ql4QqCbVwJwpDEtl' +
    'vN00zQhb5JkhTnlF02O8oG0ISOApFEugDQuRZOIFj4Hh2AMcxfTh20PuDfhfuB' +
    '32bFT0=');
main:        
if FindBitmap (x, y, Bmp, 0, 0, 2559, 1023) then
begin
WriteLn('IMG FOUND!');    
ClickMouse((x + Bmp.Width / 2),(y + Bmp.Height / 2),mbLeft);
end
else
begin
goto main
end;

end.

ClickMouse不起作用,Scar Divi说:类型不匹配

2 个答案:

答案 0 :(得分:0)

要转换数据类型,您需要"施放"它(不是"通过")。请参阅this link

ClickMouse(Integer(x + Bmp.Width / 2),Integer(y + Bmp.Height / 2),mbLeft);

当我查看definition of ClickMouse时,它不仅需要Integer,还需要const Integer所有参数:

 procedure ClickMouse(const X, Y: Integer; const Btn: TMouseButton);

definitionconst必须在编译时进行评估。如果我理解正确,那么你所采取的方法是行不通的......

答案 1 :(得分:0)

好的,坦克给所有人。 Sertac Akyuz 有解决方案:更改/为div返回一个整数。

ClickMouse((x + Bmp.Width div 2),(y + Bmp.Height div 2),mbLeft);

问题是我不能有小数点坐标。

相关问题