{**********************************************************************}
{** Note about MDI Applications                                      **}
{**              MDI Applications will have a drawing problem with   **}
{**              this caption component.  To avoid this I recommend  **}
{**              that you add code into your MainForm, so that when  **}
{**              a child form is created, then the following code    **}
{**              gets executed instead of the DELPHI supplied        **}
{**              routine for "CreateMDIChild".                       **}
{**                                                                  **}
{**              This code has been tested using an application      **}
{**              created with Delphi2's MDI application template.    **}
{**              (with a TMSOfficeCaption component added).          **}
{**                                                                  **}
{**                                                                  **}
{** What does it do?                                                 **}
{**   This code stops Windows from redrawing anything within the     **}
{**   main window.  It then updates the window with the new name and **}
{**   and tells the new child to draw itself.  This is flicker free. **}
{**   This code works for 16 and 32 bit applications.                **}
{**                                                                  **}
{**   Something similar to this may have to be implemented when the  **}
{**   user swaps between different MDI children.                     **}
{**                                                                  **}
{**********************************************************************}


procedure TForm1.CreateMDIChild(const Name: string);
var
  Child: TMDIChild;
  SuspendPainting : Boolean;
begin
  { stop false redrawing of caption (if child is maximised) }
  If ActiveMDIChild <> nil
    then SuspendPainting := IsZoomed(ActiveMDIChild.Handle)
    else SuspendPainting := false;
  if SuspendPainting then
    SendMessage(Handle, WM_SetRedraw, 0, 0); { suspend all painting within this window }


  { create a new MDI child window }
  Child := TMDIChild.Create(Application);
  Child.Caption := Name;


  { now redraw the caption and window (if child is maximised) }
  if SuspendPainting then { it is now time to resume painting }
  begin
    SendMessage(Handle, WM_SetRedraw, 1, 0); { resume painting within this window }
    Child.Invalidate;  { draw the child - since it's initial drawing was blocked }
    MSOfficeCaption1.UpdateCaption;
  end;
end;

{**********************************************************************}
