{**********************************************************************}
{** 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).          **}
{**                                                                  **}
{**              I have included three different versions for 32 bit **}
{**              applications, each with different disadvantages.    **}
{**              You can take your pick, or try to find a better one.**}
{**                                                                  **}
{** What does it do?   (32 bit)                                      **}
{** Version 1:   This code stops Windows from redrawing the caption  **}
{**              of the main window.  It then updates the caption    **}
{**              with the new name - flicker free.  The disadvantage **}
{**              is that it commits a resource to windows, and you   **}
{**              don't get the resource back until the program ends. **}
{** Version 2:   This code stops Windows from redrawing the caption  **}
{**              of the main window.  It then updates the caption    **}
{**              with the new name - flicker free.  The disadvantage **}
{**              is that every other window is forced to redraw.     **}
{** Version 3:   Similar to version 2, but it removes the redrawing  **}
{**              of other windows.  Unfortunately it is not flicker  **}
{**              free (at least not on Windows95).                   **}
{**                                                                  **}
{** Clearly an ideal solution is yet to be found.  Please e-mail me  **}
{** at wfy@ee.ed.ac.uk if you find a better solution.  Thank you.    **}
{**                                                                  **}
{** What does it do?   (16 bit)                                      **}
{**              This code paints an updated caption after the       **}
{**              default actions.                                    **}
{**********************************************************************}

--------------------------------
The 32 bit version : Version 1 :
--------------------------------
procedure TForm1.CreateMDIChild(const Name: string);
var
  Child: TMDIChild;
  FFreezer : TFreezer;
begin
  { Protect window from updates/flicker }
  If (MSOfficeCaption1 <> nil) then FFreezer := MSOfficeCaption1.Freeze;

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

  If (MSOfficeCaption1 <> nil) then MSOfficeCaption1.UnFreeze(FFreezer);
  If (MSOfficeCaption1 <> nil) then MSOfficeCaption1.UpdateCaption;
end;

--------------------------------
The 32 bit version : Version 2 :
--------------------------------
procedure TForm1.CreateMDIChild(const Name: string);
var
  Child: TMDIChild;
begin
  LockWindowUpdate(Handle);
  Child := TMDIChild.Create(Application);
  Child.Caption := Name;
  LockWindowUpdate(0);
end;

--------------------------------
The 32 bit version : Version 3 :
--------------------------------
procedure TForm1.CreateMDIChild(const Name: string);
var
  Child: TMDIChild;
begin
  Child := TMDIChild.Create(Application);
  LockWindowUpdate(Handle);
  Child.Caption := Name;
  LockWindowUpdate(0);
end;

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

--------------------
The 16 bit version :
--------------------
procedure TForm1.CreateMDIChild(const Name: string);
var
  Child: TMDIChild;
begin
  { create a new MDI child window }
  Child := TMDIChild.Create(Application);
  Child.Caption := Name;

  If ((MSOfficeCaption1 <> nil) and (Child.WindowState=wsMaximized))
    then MSOfficeCaption1.UpdateCaption;
end;
