[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 MDI Commands    -   Multiple Document Interface = MDI
--------------------------------------------------------------------------------

 See below for a full explanation about Windows MDI use.

 Creating a MDI frame Window is
 done in a very similar way as
 a normal Window. The difference
 is just specify MDI

         DEFINE WINDOW <oWnd> ;
             [ FROM <nTop>, <nLeft> TO <nBottom>, <nRight> ] ;
             [ TITLE <cTitle> ] ;
             [ STYLE <nStyle> ] ;
             [ MENU  <oMenu> ] ;
             [ BRUSH <oBrush> ] ;
             [ ICON  <oIcon> ] ;
             [ MDI ] ;
             [ COLOR <nClrText>, <nClrPane> ] ;
             [ VSCROLL | VERTICAL SCROLL ] ;
             [ HSCROLL | HORIZONTAL SCROLL ] ;
             [ MENUINFO <nMenuInfo> ]

 See Window creating commands, as all the items are the same except:

 MDI             Specify that the main Window is going to be a MDI Window

 <nMenuInfo>     Is the position of the PopUp at the PullDown menu where
                 Windows automatically reports which child Window is
                 activated.

 Activation Commands are the same as with a normal Window.

 To create a ChildWindow of the main MDI Window, we do again in a very
 similar way as creating a Window:

          DEFINE WINDOW [<oWnd>] ;
             [ MDICHILD ] ;
             [ FROM <nTop>, <nLeft> TO <nBottom>, <nRight> ] ;
             [ TITLE <cTitle> ] ;
             [ MENU <oMenu> ] ;
             [ ICON <oIco> ] ;
             [ OF <oParent> ]

 You must specify the clause MDICHILD to have all the posibilities Windows
 MDI offers.

                        MDI programming explanation

 What is MDI ?

 As soon as you start getting confortable with Windows you will face one
 of the more powerfull features of it: Multiple Document Interface Windowing.

 Most of the Windows commercial applications we use (the same Windows Program
 Manager is written using MDI) take advantage of the possibilities of MDI.

 Basicly MDI enviroment is a main Window which has several child Windows
 inside which can be resized, tiled, cascaded, maximized, created and destroyed
 very easily. In fact, a MDI enviroment is like a whole Window enviroment
 itself again.

 This features which may seems for you now very common, don't work if you
 try to get it using standard Windows. Well, you could do it, but it would
 means a lot of code to be done.

 Windows offers MDI system to automatically have all that.

 Why MDI ?

 To easier things. We get automatically a lot of nice and powefull features
 without the need to code them. Windows takes control of everything!

 The elements of a MDI enviroment

 There is just one big diference to understand about MDI programming:

 Windows, to easier things, keeps an 'invisible' Window which extends all
 the client area of the 'frame' Window:

                     +---------------------------------------+
 MDI Frame --------->|+-------------------------------------+|
 (is the external    ||            +---------------+        ||
  and main Window)   ||            |               |        ||
                     ||            |            <-------------- Child Windows
                     ||            |               |        || | (In fact they
 MDI Client ---------------->      |     +----------------+ || | are child of
 (you don't realize  ||            +-----|                | ||   the MDI client
  it is there and    ||                  |      <--------------| Window)
  extends all the    ||                  |                | ||
  internal area of   |+-------------------------------------+|
  the MDI frame)     +---------------------------------------+


 The real 'trick' of the MDI programming is the MDI Client Window wich Windows
 has implemented to easier things.

 Developing a MDI enviroment in C language is a very complicated task. In
 fact is one of the most dificults task for beginners. But you are luck
 because doing it with CA-Clipper and FiveWin it is a very, very easy task!


 How to do MDI with FiveWin

 To create the main MDI frame Window we use the standard FiveWin Windows
 creating commands, the only difference is that you must especify the
 MDI clause. See above.

 Now, you start creating the child Windows with the same easy commands.
 You don't have to worry at all about the 'ghost' MDI Client Window.

 FiveWin automatically manages and talk to the MDI Client Window.

 To create a MDI Child Window you use again the standard Window creating
 commands, but you must especify the clause MDICHILD.

 All that you already know about FiveWin is still the same! You only have
 to remeber some few ideas:

 MDI Frame Window Object has a 'DATA' named oWndClient, which is another
 Windows Object -the 'ghost' MDI Client!-.

 In fact, the surface you see inside the MDI frame is the MDI Client!!!
 Don't forget that. So, if -for example- you plan to place a bitmap on
 the surface of the MDI frame Window, in fact you have to place it at the
 MDI Client. So remember to do this:

 @ 2, 2 BITMAP ... OF oWnd:oWndClient

 if you forget that, and you just do OF oWnd, you will be placing the bitmap
 _behind_ the MDI Client, so you will not see the bitmap!!! Remember that!
 That is all the 'trick' about MDI programming.

 MDI Object Oriented Implementation

 If you go deeper in FiveWin architecture, you will discover there are some
 very powerfull Classes supporting all the Windows MDI implementation.

 We have developed three main Classes which all inherits from base Window Class:

            Class TWindow
            |
            |-- Class TMdiFrame
            |-- Class TMdiClient
            +-- Class TMdiChild

 Every of them implements new methods to encapsulate all the power Windows
 offers to MDI programming.

 Remember this:

 TMdiFrame is the main Window. It has a data named oWndClient which it is
 a TMdiClient Window.

 oWndClient has a Clipper array with all the Child Windows you create.
 The name of that data is aWnd. It is a normal Clipper array. You may use
 as you wish.

 New MDI directions in FiveWin

 In previous releases of FiveWin, we planed to develop some new Classes
 inheriting from TMdiChild to suit some of the 'normal' bussines aplications
 situations you will normally face. But now, with FiveWin 1.5 we have found
 an easier approach:

 Most of the MDI Child Windows you will use there will be very similar
 each other -once again we stress about bussines applications development
 not just 'fancy' programming-. They will have a ButtonBar attached and
 a main control which automatically resizes to extend the whole visible
 area of the Child Window.

 So, we are offering you a real powerfull way of developing MDI enviroments
 very quickly and clean:

 The way we propouse you to manage MDI child Windows is a follows:

 * First at all you create the MDI frame. See above sintax.

 * Next you start creating -when you need them- the child Windows:
   Using the above syntax:

          DEFINE WINDOW [<oWnd>] ;
             [ MDICHILD ] ;
             [ FROM <nTop>, <nLeft> TO <nBottom>, <nRight> ] ;
             [ TITLE <cTitle> ] ;
             [ MENU <oMenu> ] ;
             [ ICON <oIco> ] ;
             [ OF <oParent> ]

 * Now you create a ButtonBar for this Child Window. Use the standard
   syntax:

       DEFINE BUTTONBAR oBar OF <oWndChild>    // The name of your MDI Child

   Attach the buttons in a normal way. Every button will have the actions
   you define:

       DEFINE BUTTON OF oBar ACTION ...

       DEFINE BUTTON OF oBar ACTION ...

       ...

   Using this way you are easily enhancing the functionality of the MDI
   Child Window without needing to develop a new Class -you are free to
   do it, but only when really needed!-

 * The last step is to create a Control -whatever Class of control you need-
   and attach it to the Child Window:

   @ 0, 0 GET <oControl>... MEMO OF <oWndChild>

   @ 0, 0 LISTBOX <oControl> BROWSE ... OF <oWndChild>

   etc...   -any Class of Control-

   And now, we tell the MDI Child to use that control as its main Control:

   <oWndChild>:SetControl( <oControl> )


   To start using it, you ACTIVATE the Window in a normal way:

   ACTIVATE WINDOW <oWndChild> ...


   And that is all!


   Using this way you will be mastering MDI programming in a few minutes
   without the need to create new Classes or learning very difficult MDI
   programming rules.

   Let CA-Clipper and FiveWin do the hardwork for you. This is the power
   of OOPS and xBase!

   See the new version of \IDE\IDE.prg for a real full example on MDI
   programming.

See Also: TMdiFrame TMdiClient TMdiChild TWindow Window.ch
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson