gpt4 book ai didi

delphi - 没有可以使用这些参数调用的 'SendMsg' 的重载版本

转载 作者:行者123 更新时间:2023-12-03 15:56:52 25 4
gpt4 key购买 nike

我正在将项目从 Delphi 2006 升级到 Delphi XE2,并且遇到了编译错误没有可以使用这些参数调用的“SendMsg”的重载版本。这是问题所在的代码。

procedure TMessageComms.UpgradeError(Msg: String);
begin
FConnection.SendMsg(cUpgradeError, Msg, FConnection.GetNextMsgID);
end;

SendMsg 方法如下所示。

procedure SendMsg(ACommand, AParamStr : String; AMsgID : Integer); overload;

procedure TMsgConnection.SendMsg(ACommand, AParamStr: String; AMsgID: Integer);
begin
// construct message
// send message
end;

cUpgradeError 是一个像这样声明的 const。

 cUpgradeError = 'UpgradeError';

这是返回 Integer 的 GetNextMsgID 函数。

function TMsgConnection.GetNextMsgID: Integer;
begin
Inc(FLastMsgID);
Result := FLastMsgID;
end;

这些参数对我来说似乎都是有效的。我已经设法将其范围缩小到与 GetNextMsgID 函数有关但不确定是什么。如果我将从函数返回的值转换为整数,那么它可以正常编译,但我不明白为什么我必须这么做。

最佳答案

我的猜测是 FConnection.SendMsg(cUpgradeError, Msg, FConnection.GetNextMsgID); 试图将 FConnection.GetNextMsgID 解释为函数指针而不是函数结果。

将其更改为FConnection.SendMsg(cUpgradeError, Msg, FConnection.GetNextMsgID());,以便清楚地表明您正在寻找函数结果。

关于delphi - 没有可以使用这些参数调用的 'SendMsg' 的重载版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14410651/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com