title: Why do modal Delphi forms not receive WM_SYSCOMMAND when the user clicks the task bar button?
body: <p>In a Delphi (2007) program, running on Windows 8.1, I would like to get notified when the user clicks on the task bar button belonging to my program. So I am trapping the WM_SYSCOMMAND which usually gets send in that case.</p>
  
  <p>This works fine for program's main window.</p>
  
  <p>If a modal window is active (opened with Form2.ShowModal), the same code cannot trap the WM_SYSCOMMAND, neither in the main for nor in the modal form. What is different? And is there any way to change this?</p>
  
  <p>This is the code I have added to both forms:</p>
  
  <pre><code>unit unit1;
  
  interface
  
  type
    TForm1 = class(TForm)
      // [...]
      procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
    end;
  
   // [...]
  
  implementation
  
   // [...]
  
  procedure Tf_dzProgressTest.WMSysCommand(var Msg: TWMSysCommand);
  begin
    inherited; // place breakpoint here
  end;
  
   // [...]
  
  end.
  </code></pre>
  
  <p>I also tried to use Application.OnMessage or a TApplicationEvents component and even overriding the form's WndProc method. Neither could trap WM_SYSCOMMAND while a modal form was active.</p>