To conclude this section, let's take a look at creating MDI applications separately. A multi-document interface can be built either manually or using MCK. But in any case, the conditional compilation symbol should be added to the project options USE_MDI (This is done both to save code and to improve performance for all other cases - when an MDI interface is not required.)... With manual coding, the first step is to create a client window that is a child of the form. A common practice when designing an MDI interface is to use the entire form space except for the main menu, the toolbar (if present), and the status bar (also optional) for the client area. But it is not forbidden to place other visual elements, for example, on the sides of the client area. Client creation is done by calling the function
NewMDIClient (ParentForm, WindowMenuHandle)
Pay attention to the parameter WindowMenuHandle. This is a handle to a submenu where the system will automatically add the names of MDI child windows. If you specify 0 as this parameter, but the window names will not be added. If such a possibility is desired, then you should first create the main menu, and then pass the descriptor of the desired submenu as the second parameter. For example, like this:
var MainMenu: PMenu;
MainForm, MDI_Client: PControl;
MainMenu: = NewMenu (MainForm, 0, [
'New', '(', 'Create MDI Child', ')',
'Window', '(', 'Tile', 'Cascade', ')', ''],
TOnMenuItem (MakeMethod (nil, @MenuItems)));
MDI_Client: = NewMDIClient (MainForm,
GetSubMenu (MainMenu, 1));
To create MDI child windows, use the function
NewMDIChild (ParentMDIClient, 'MDIChildName');
There can be several such windows, they can be created dynamically, which is quite common for an MDI interface. On such a child window, arbitrary visual elements can be located, as on a regular panel. When developing child windows, it should be taken into account that their sizes can change, in particular, the window can be maximized over the client window.
Visual development of an MDI interface using MCK is also possible. For which there are mirror classes TKOLMDIClient and TKOLMDIChild. It is likely that only the first of them will be useful, while child windows will still have to be created dynamically. To simplify creation, it is recommended to use TKOLFrame, on which the necessary visual objects are placed in development mode, and at runtime the resulting set of objects is simply cloned by calling the corresponding function.
|
It should be noted that some operations with MDI windows are performed in a slightly different way than with ordinary visual objects. For example, to programmatically maximize a certain client window, it is preferable to use sending a WM_MDIMAXIMIZE message to the client window, although it is possible to send a WM_SYSCOMMAND message with wParam = SC_MAXIMIZE to the child window itself. |