title: strange behavior of child windows after setParent
body: <p>I tried to embedded "Windows Journal" application in my Winform application by using following code. It works and everything looks good. However, when I start using Windows Journal application, which is already a child window of my application, I found the mouse behave inconsistent. Be more specific, for example, I tried to draw a line from (x, y) to (x+100, y), but the line show up on the window at (x-50, y-50) to (x, y-50). I have googling by using keywords “Mouse synchronize/inconsistent”, “application abnormal behavior after setparent, “Strange behavior of child-windows”, but not found any related solution yet. I also tried to clear the WS_POPUP style before setParent, but it didn't work. 
  Could anyone give me some ideas? Thanks.</p>
  
  <pre><code>//IntPtr appWin is the MainWindowHandle of Windows Journal process 
  ShowWindowAsync(appWin, SW_SHOWNORMAL);
  
  // Put it into this form
  SetParent(appWin, this.Handle);
  
  // Remove border and whatnot
  SetWindowLong(appWin, GWL_STYLE, WS_VISIBLE);
  
  // Move the window to overlay it on this window
  MoveWindow(appWin, 0, 0, this.Width, this.Height, true);
  </code></pre>
  
  <p>The code is resides in a Controller called JournalControl.cs and JournalControl is located in a splitContainer.Panel in the Main Form of the application. So, when a button of the main form be clicked, first, open a jnt file which the user indicates in Journal application</p>
  
  <pre><code>public void OpenJournal(string JNTPath)
  {
      try
      {
          if (File.Exists(JNTPath))
          {
              proc.StartInfo.FileName = @"C:\Program Files\Windows Journal\Journal.exe";
              proc = Process.Start(JNTPath); 
  
              this.timCheckJournal = new System.Windows.Forms.Timer();
              this.timCheckJournal.Tick += new System.EventHandler(this.timCheckJournal_Tick);          
          }
          else
          {
              MessageBox.Show("Couldn't find  JNTPath: " + JNTPath);
          }
      }
      catch (Exception ex)
      {
          ExceptionPublisher.PublishEx(ex);
      }
  } 
  </code></pre>
  
  <p>Then in timCheckJournal_Tick(), puts the application inside the Panel</p>
  
  <pre><code>private void timCheckJournal_Tick(object sender, EventArgs e)
  {
      timCheckJournal.Enabled = false;
      IntPtr appWin = GetJournalTopWindowHandle();
      if (appWin != IntPtr.Zero)
      {
          ShowWindowAsync(appWin, SW_SHOWNORMAL);
  
          // Put it into this form
          SetParent(appWin, this.Handle);
  
          // Remove border and whatnot
          SetWindowLong(appWin, GWL_STYLE, WS_VISIBLE);
  
          // Move the window to overlay it on this window
          MoveWindow(appWin, 0, 0, this.Width, this.Height, true);
      }
      else
      {
          timCheckJournal.Enabled = true;
      }
  }
  </code></pre>