title: Delphi thread not receiving messages
body: <p>I am developing an application with multithreading (RAD Studio XE5). At the start of the application I create a single thread that will live as long as the main form does.</p>
  
  <p>I am able to dispatch messages from the thread to any form that has been created in my application, however I can't find a way to do the opposite, sending a message from the main VCL thread to the worker thread.</p>
  
  <p>When creating the main form I create the worker thread and copy the handle in a public variable:</p>
  
  <pre><code>  serverThread := TMyThread.Create(True, ServerPort + 1);
    serverThreadHandle := serverThread.Handle; // SAVE HANDLE
    serverThread.Start;
  </code></pre>
  
  <p>then (from a different form FrmSender) I dispatch a message to the thread:</p>
  
  <pre><code>  PostMessage(uMain.serverThreadHandle, UM_LOC_VCLMSG, UM_LOC_VCLMSG, Integer(PStrListVar));
  </code></pre>
  
  <p>This is the thread's Execute procedure:</p>
  
  <pre><code>procedure TMyThread.Execute;
  var
      (..)
      vclMSG : TMsg;
      str1, str2 : string;
      (..)
  begin
      while not(Terminated) do
      begin
          Sleep(10);
          if Assigned(FrmSender) then
            if FrmSender.HandleAllocated then
              if PeekMessage(vclMSG, FrmSender.Handle, 0, 0, PM_NOREMOVE) then
                begin
                  if vclMSG.message = UM_LOC_VCLMSG then
                    begin
                      try
                        pStrListVar := pStrList(vclMSG.lParam);
                        str1 := pStrListVar^.Strings[0];
                        str2 := pStrListVar^.Strings[1];
                      finally
                        Dispose(pStrListVar);
                      end;
                    end;
                end;  
          (.. do other stuff ..)
      end;
  end;
  </code></pre>
  
  <p>However <strong>PeekMessage()</strong> never returns true as if it was never receiving any message. I've tried changing the parameters to <strong>PeekMessage()</strong>:</p>
  
  <pre><code>PeekMessage(vclMSG, 0, 0, 0, PM_NOREMOVE);
  </code></pre>
  
  <p>But with no results.
  Any ideas?</p>