To add event handlers for the New child and Close All commands

  1. If necessary, open the Menu designer and select New child.
  2. In the Object Inspector, double-click the OnClick event on the Events tab.

The Code editor displays with the cursor in the TfrMain.mnNewChildclick event handler block.

3. At the cursor, enter the following code:

CreateChildForm('Child '+IntToStr(MDIChildCount+1));

  1. In the Menu designer, select Close All.
  2. In the Object Inspector, double-click the OnClick event on the Events tab.

The Code editor displays with the cursor in the TfmMain.mnCloseAllClick event handler block.

6. At the cursor, enter the following code:

for i:=0 to MDIChildCount - 1 do MDIChildren[i].Close;

7. Just before the code block in the event handler, declare the local variable i.

The first two lines of the event handler code should appear as shown here when you are done:

procedure TfrMain.mnCloseAllClick(Sender: TObject); var i: integer;

Note: The event handler minimizes the child window in the main window. To close the child window, you must add an OnClose procedure to the child form (next).

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment