C++Builder 程序员博客
13 Nov
我在用Iocomp控件的iSpectrumDisplay频谱显示功能,按照帮助文档利用设置Bar的值,
const double aa=9.0;
Form1->iSpectrumDisplay1->SetBarValue(3,aa);
编译报错,显示:E2247 '_fastcall TiSpectrumDisplay::SetBarValue(int,const double)'is not accessible ,
这是什么意思,我已经安装该函数说明送数据了,请教各位了。谢谢。
我跟踪了函数,是在public区域的,有其他办法吗?
//那怎么会呢,方便把TiSpectrumDisplay类的头文件里的代码贴出来么?
不好意思,看错了。
跟踪后,发现在iSpectrumDisplay.hpp文件,protected下的void __fastcall SetBarValue(int Index, const double Value);
在头文件的说明:
procedure SetBarValue (Index: Integer; const Value: Double);
.
.
property BarValue [Index : Integer] : Double read GetBarValue write SetBarValue;
.
.
procedure TiSpectrumDisplay.SetBarValue(Index: Integer; const Value: Double);
begin
if (Index < 0) or (Index > FBarCount - 1) then raise Exception.Create('Index out of Bounds');
FData[Index].Value := Value;
if Value > FData[Index].Peak then
begin
FData[Index].Peak := Value;
FData[Index].PeakUpdateTime := Now;
end;
InvalidateChange;
end;
那只要改成:Form1->iSpectrumDisplay1->BarValue[3] = aa; 就可以了
/* 嗯 ,赞同毛毛的意见! 你直接操作它的属性BarValue就可以了,其内部就是调用 保护成员方法SetBarValue,外部对象不可以直接调用保护成员 的方法! */
谢谢,我知道了