{**********************************************************************}
{** 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?   (32 bit)                                      **}
{**              This code stops windows from redrawing the caption  **}
{**              of the main window.  It then updates the caption.   **}
{**                                                                  **}
{** What does it do?   (16 bit)                                      **}
{**              This code paints an updated caption after the       **}
{**              default actions.                                    **}
{**********************************************************************}

--------------------
The 32 bit version :
--------------------

procedure TForm1.CreateMDIChild(const Name: string);
var
  Child: TMDIChild;
  RgnIsNull : Boolean;
  temp      : longint;
  OldWinRgn : HRgn;  { The value initially held as the window's region }
begin
  If (MSOfficeCaption1 <> nil)
  then begin
    OldWinRgn  := CreateRectRgn(0,0,Width,Height);  { create OldWinRgn }
    temp  := longint(GetWindowRgn(Handle, OldWinRgn)); { store existing Window Region }
    RgnIsNull := ((temp = error) or (temp = NullRegion));     { is it a null region ?? }
    SetWindowRgn(Handle, MSOfficeCaption1.GetWindowRgn_NoCaption, False);
  { create a new MDI child window }
    Child := TMDIChild.Create(Application);
    Child.Caption := Name;
    { restore previous Window Region }
    if RgnIsNull
    then begin
      SetWindowRgn(Handle, 0, false);
      DeleteObject(OldWinRgn);
    end else
      SetWindowRgn(Handle, OldWinRgn, false);
    MSOfficeCaption1.UpdateCaption;
    exit;
  end;
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;
