楼上的办法肯定不行的。
window child
OpenSheet(child,"w_ghjld",parentwindow,0,original!)
这样的代码,child 是局部变量,打开窗口以后就被赋了一个窗口对象的引用,然后事件结束,变量被释放。而打开的窗口就无法再被引用了。
解决办法:使用全局变量或主窗口主菜单一级的实例变量数组,能够在整个程序生命期保存所有的sheet的引用。同时所有的打开sheet的动作都必须改变这个数组。
我在主窗口建立了一个实例变量window w[],和一个窗口函数,参数为as_sheetname,代码如下
//window w[]
long i,u
boolean sh
u=upperbound(w)
sh=keydown(keyshift!)
for i=1 to u
if isnull(w[i]) then
exit
end if
if not isvalid(w[i]) then
exit
end if
if (not sh) and w[i].classname()=as_sheetname then
exit
end if
next