title: AppendMenu doesn't work when ModalPopupMode=pmAuto
body: <p>In Delphi, i use the following line (and others, almost identical) to add items to the system menu of forms:</p>
  
  <pre><code>AppendMenu(GetSystemMenu(Self.Handle, False), MF_BYPOSITION, cSetScreenResolution1024x768,  PChar('1024x768'));
  </code></pre>
  
  <p>This is part of a class that all other forms inherit from, and it works fine most of the time, but I've noticed that when forms are opened in modal mode the custom menuitems aren't there. When the same form is opened in modeless mode it works just fine. I've spent some time figuring out why, and I have found that if <strong>ModalPopupMode=pmAuto</strong> I get this error. When it's <strong>pmNone</strong>, things work just fine.</p>
  
  <p>Can anyone explain why this happens? And maybe give advise on how to solve it? I use ModalPopupMode=pmAuto to fix other issues, so it's not a good alternative to revert it to pmNone. </p>
  
  <p>To reproduce, just make a small project with two forms. Drop two buttons on the first form, one to open the second form modally, one to open it modeless. Put this line into the second form's create:</p>
  
  <pre><code>AppendMenu(GetSystemMenu(Self.Handle, False), MF_BYPOSITION, 10000,  PChar('1024x768'));
  </code></pre>
  
  <p>It will now work as expected. Now set the applications ModalPopupMode to pmAuto, and observe that the extra menuitem on the systemmenu has disappeared when opening the form modally.</p>
  
  <p>Alternatively (and maybe more conveniently?) copy these 5 "files":</p>
  
  <p>PROJECT1.DPR</p>
  
  <pre><code>program Project1;
  
  uses
    Forms,
    Unit1 in 'Unit1.pas' {Form1},
    Unit2 in 'Unit2.pas' {Form2};
  
  {$R *.res}
  
  begin
    Application.ModalPopupMode := pmAuto;
    Application.Initialize;
    Application.MainFormOnTaskbar := True;
    Application.CreateForm(TForm1, Form1);
    Application.Run;
  end.
  </code></pre>
  
  <p>UNIT1.PAS</p>
  
  <pre><code>unit Unit1;
  
  interface
  
  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;
  
  type
    TForm1 = class(TForm)
      Button1: TButton;
      Button2: TButton;
      procedure Button1Click(Sender: TObject);
      procedure Button2Click(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  var
    Form1: TForm1;
  
  implementation
  
  uses Unit2;
  
  {$R *.dfm}
  
  procedure TForm1.Button1Click(Sender: TObject);
  begin
    with TForm2.Create(nil) do
    try
      ShowModal;
    finally
      Free;
    end;
  end;
  
  procedure TForm1.Button2Click(Sender: TObject);
  begin
    with TForm2.Create(Application.Mainform) do
    begin
      show;
    end;
  end;
  
  end.
  </code></pre>
  
  <p>UNIT1.DFM</p>
  
  <pre><code>object Form1: TForm1
    Left = 0
    Top = 0
    Caption = 'Form1'
    ClientHeight = 337
    ClientWidth = 635
    Color = clBtnFace
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []
    OldCreateOrder = False
    PixelsPerInch = 96
    TextHeight = 13
    object Button1: TButton
      Left = 8
      Top = 8
      Width = 75
      Height = 25
      Caption = 'Modal'
      TabOrder = 0
      OnClick = Button1Click
    end
    object Button2: TButton
      Left = 8
      Top = 39
      Width = 75
      Height = 25
      Caption = 'Modeless'
      TabOrder = 1
      OnClick = Button2Click
    end
  end
  </code></pre>
  
  <p>UNIT2.PAS</p>
  
  <pre><code>unit Unit2;
  
  interface
  
  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs;
  
  type
    TForm2 = class(TForm)
      procedure FormCreate(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  implementation
  
  {$R *.dfm}
  
  procedure TForm2.FormCreate(Sender: TObject);
  begin
    AppendMenu(GetSystemMenu(Self.Handle, False), MF_BYPOSITION, 10000,  PChar('Test'));
  end;
  
  end.
  </code></pre>
  
  <p>UNIT2.DFM</p>
  
  <pre><code>object Form2: TForm2
    Left = 0
    Top = 0
    Caption = 'Form2'
    ClientHeight = 337
    ClientWidth = 635
    Color = clBtnFace
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []
    OldCreateOrder = False
    OnCreate = FormCreate
    PixelsPerInch = 96
    TextHeight = 13
  end
  </code></pre>