我在主窗体启动时,控制另一窗体的控件。以下是代码,为什么总说对象不对。因为,有控件的窗体,我是在主窗体的时候分成了四个相等的窗体fmBedObjList[i]。 procedure TfmMain.FormCreate(Sender: TObject); var ... begin for i=0 to 3 do fmBedObjList[i].Panel6.Visible := true ; fmBedObjList[i].Panel7.Visible := true; fmBedObjList[i].Panel8.Visible := true; fmBedObjList[i].Panel9.Visible := true; ... end;编译运行时提示错误: --------------------------- Debugger Exception Notification --------------------------- Project RemoteII.exe raised exception class EAccessViolation with message 'Access violation at address 0053688B in module 'RemoteII.exe'. Read of address 0000039C'. Process stopped. Use Step or Run to continue. ---------------------------
引用了一个未实例化的对象Project --> Options --> Forms --> Auto Create Form: fmBedObjList应位于frmMain之前
可以定义全局变量再上一个窗体的checkbox选中的时候更新这个变量这样在这个创体现是的时候来判断这个变量决定是否显示控件!
procedure TfmMain.FormCreate(Sender: TObject);
var
...
begin
for i=0 to 3 do
fmBedObjList[i].Panel6.Visible := true ;
fmBedObjList[i].Panel7.Visible := true;
fmBedObjList[i].Panel8.Visible := true;
fmBedObjList[i].Panel9.Visible := true;
...
end;编译运行时提示错误:
---------------------------
Debugger Exception Notification
---------------------------
Project RemoteII.exe raised exception class EAccessViolation with message 'Access violation at address 0053688B in module 'RemoteII.exe'. Read of address 0000039C'. Process stopped. Use Step or Run to continue.
---------------------------
如果不行,把代码在贴的详细一些
确认你要判断CHECKED的那个窗体是否已经加载