创建2个不同的mdi子窗体的问题 ( 积分: 50 )

  • 主题发起人 主题发起人 mazheng
  • 开始时间 开始时间
M

mazheng

Unregistered / Unconfirmed
GUEST, unregistred user!
如代码,有时会出现这样的错误“name ont unique in this context” 如何处理〉??
//==============================================================================
procedure TmainFrm.N2Click(Sender: TObject);
var
newFrm: TDbmaterialFrm;
i,flag:integer;
begin
flag:=0;
for i:=0 to mainFrm.MDIChildCount do
begin
if mainFrm.MDIChildren.Caption='总物料管理' then
begin
SendMessage(mdichildren.Handle, WM_SYSCOMMAND, SC_restore, 0);
mdichildren.Show;
mdichildren.Enabled:=true;
flag:=1;
break;
end;
end;
if flag=0 then
begin
newFrm:=TDbmaterialFrm.Create(Application);
newFrm.Caption:='总物料管理';
end;
end;
//==============================================================================
procedure TmainFrm.N3Click(Sender: TObject);
var
//CalendarFrm: TCalendarFrm;
newFrm: TRomFrm;
i,flag:integer;
begin
flag:=0;
for i:=1 to mainFrm.MDIChildCount do
begin
if mainFrm.MDIChildren.Caption='物料清单' then
begin
SendMessage(mdichildren.Handle, WM_SYSCOMMAND, SC_restore, 0);
mdichildren.Show;
mdichildren.Enabled:=true;
flag:=1;
break;
end;
end;
//若窗体不存在,则创建窗体
if flag=0 then
begin
newFrm:=TRomFrm.Create(Application);
newFrm.Caption:='物料清单';
end;
end;
 
如代码,有时会出现这样的错误“name ont unique in this context” 如何处理〉??
//==============================================================================
procedure TmainFrm.N2Click(Sender: TObject);
var
newFrm: TDbmaterialFrm;
i,flag:integer;
begin
flag:=0;
for i:=0 to mainFrm.MDIChildCount do
begin
if mainFrm.MDIChildren.Caption='总物料管理' then
begin
SendMessage(mdichildren.Handle, WM_SYSCOMMAND, SC_restore, 0);
mdichildren.Show;
mdichildren.Enabled:=true;
flag:=1;
break;
end;
end;
if flag=0 then
begin
newFrm:=TDbmaterialFrm.Create(Application);
newFrm.Caption:='总物料管理';
end;
end;
//==============================================================================
procedure TmainFrm.N3Click(Sender: TObject);
var
//CalendarFrm: TCalendarFrm;
newFrm: TRomFrm;
i,flag:integer;
begin
flag:=0;
for i:=1 to mainFrm.MDIChildCount do
begin
if mainFrm.MDIChildren.Caption='物料清单' then
begin
SendMessage(mdichildren.Handle, WM_SYSCOMMAND, SC_restore, 0);
mdichildren.Show;
mdichildren.Enabled:=true;
flag:=1;
break;
end;
end;
//若窗体不存在,则创建窗体
if flag=0 then
begin
newFrm:=TRomFrm.Create(Application);
newFrm.Caption:='物料清单';
end;
end;
 
newFrm1 : TDbmaterialFrm;
newFrm2 : TDbmaterialFrm;
 
为什么????????????/
 
某个窗体或控件名称与另一个窗体或控件名相同
 
for i:=0 to mainFrm.MDIChildCount do 是否应改成for i:=0 to mainFrm.MDIChildCount-1 do?因为索引从0开始啊。
定义变量时加上private试试看能不能解决标志符重复问题。
 
后退
顶部