本人想在MDI父窗体上的工具栏中放置一按钮,在打开多个MDIChild子窗体时,点击这个按钮可以实际逐个把当前活动的窗口关闭,如果没有打开任何子窗体时,就完全退出程序。如果实际呢?

解决方案 »

  1.   


    if MdiParent.MdiChildCount = 0 then
       application.Terminate
    else
    for i := 0 to MdiParent.MDIChildCount - 1 do
    begin
      if MdiParent.MdiChildren[i] = self then
      begin
         Close; 
         break;
      end;
    end;
      

  2.   

    if MdiParent.MdiChildCount = 0 then
       application.Terminate
    else
    for i := 0 to MdiParent.MDIChildCount - 1 do
    begin
      if MdiParent.MdiChildren[i] = self then
      begin
         Close; 
         break;
      end;
    end;
      

  3.   

    if MdiParent.MdiChildCount = 0 then
       application.Terminate
    else
    for i := 0 to MdiParent.MDIChildCount - 1 do
    begin
      if MdiParent.MdiChildren[i] = self then
      begin
         Close; 
         break;
      end;
    end
      

  4.   

    if MdiParent.MdiChildCount = 0 then
       application.Terminate
    else
    for i := 0 to MdiParent.MDIChildCount - 1 do
    begin
      if MdiParent.MdiChildren[i] = self then
      begin
         Close; 
         break;
      end;
    end
      

  5.   

      if ActiveMDIChild = nil then
        Application.Terminate
      else
        ActiveMDIChild.Close;
      

  6.   

    是可以了,但关闭活动的MDIChild子窗体时是需要确定是否真的要关闭,如果选择是或者否能在这里返回一个值吗
      

  7.   

    在 oncloseQuery 里加个代码canclose := application.MessageBOx('确要退出吗?','提示',MB_OKCancel+MB_IConInformation) = ID_OK;