高手赐教郁闷我一天的问题:Acceess violation 问题(10分)

  • 主题发起人 ruoxi_shuai
  • 开始时间
R

ruoxi_shuai

Unregistered / Unconfirmed
GUEST, unregistred user!
通过点击主窗体的菜单按钮,生成窗体1(ConfigerManagement),在窗体1中再点击弹出菜单生成窗体2(AddSunItem),此时窗体不能显示出现Acceess violation 异常,主窗体、窗体1中的按钮事件代码如下:<br>//主窗体<br>procedure TMain.N24Click(Sender: TObject);<br>begin<br>&nbsp; with &nbsp;TConfigerManagement.Create(nil) do<br>&nbsp; try<br>&nbsp; &nbsp; showmodal;<br>&nbsp; finally<br>&nbsp; &nbsp; free;<br>&nbsp; end;<br>end;<br><br>//窗体1<br>procedure TConfigerManagement.N1Click(Sender: TObject);<br>begin<br>&nbsp; level:=treeview1.Selected.Level;<br>&nbsp; with TAddSunItem.Create(nil) do<br>&nbsp; try<br>&nbsp; &nbsp; ShowModal;<br>&nbsp; finally<br>&nbsp; &nbsp; Free;<br>&nbsp; end;<br>end;<br>//窗体2的Onshow()<br>procedure TAddSunItem.FormShow(Sender: TObject);<br>begin<br>&nbsp; edit1.Text:=ConfigerManagement.TreeView1.Selected.Text;<br>&nbsp; //根据不同的层次节点生成不同的添加界面<br>&nbsp;case ConfigerManagement.TreeView1.Selected.level of<br>&nbsp; 0: begin<br>&nbsp; &nbsp; &nbsp; &nbsp;combobox1.Visible:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp;label4.Visible:=true;<br>&nbsp; &nbsp; &nbsp; &nbsp;label5.Visible:=true;<br>&nbsp; &nbsp; &nbsp; &nbsp;edit2.Visible:=true;<br>&nbsp; &nbsp; &nbsp; &nbsp;edit3.Visible:=true;<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; 2: ;<br>&nbsp; 1,3: begin<br>&nbsp; &nbsp; &nbsp; &nbsp;combobox1.Visible:=true;<br>&nbsp; &nbsp; &nbsp; &nbsp;label4.Visible:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp;label5.Visible:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp;edit2.Visible:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp;edit3.Visible:=false;<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; 4: begin<br>&nbsp; &nbsp; &nbsp; &nbsp;combobox1.Visible:=true;<br>&nbsp; &nbsp; &nbsp; &nbsp;label4.Visible:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp;label5.Visible:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp;edit2.Visible:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp;edit3.Visible:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp;memo1.Enabled:=true;<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; else ;<br>&nbsp; end;<br>end;
 
自己顶一下,在线等,高了一上午了没搞明白那里出问题,感觉没有访问违规的地方呀!
 
你要自己调试,逐步运行,可以很快找到问题所在.猜测是treeview1.Selected=nil造成的访问错误.
 
说一下,要是让窗体1(ConfigerManagement)自动生成再调用窗体2就没事什么问题了,各种操作均可以完成
 
把窗体2的Onshow()代码写在它的OnCreate()中试试
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部