title: window is continuously getting WM_WINDOWPOSCHANGING
body: <p>I have created a window and embedding a CAxWindow inside that parent window.</p>
  
  <p>When I create main window I also create CAxWindow window . NOw issue is that I have added WM_WINDOWPOSCHANGING message in my main window and its getting called continuously. Initially its getting called with right coordinate vales but after some time its getting called wit x=0,y=0 , width and height=0.</p>
  
  <p>Any ideas why this is happening? </p>
  
  <p>If I put breakpoint in OnWindowPosChanging, I can see pwp->x=0,pwp->y=0,pwp->cx=0,pwp->cy=0</p>
  
  <p>Here is code</p>
  
  <pre><code>#include &lt;atlbase.h&gt;
  #include &lt;atlwin.h&gt;
  #include &lt;atlcom.h&gt;
  CComModule _Module;
  
  // To create an ATL window, begin by deriving from CWindowImpl&lt;&gt;.
  class CMainWindow : public CWindowImpl&lt;CMainWindow, CWindow,
       CWinTraits&lt;WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE, 0 &gt; &gt;
  {
  public:
       CMainWindow(const RECT rect);
       virtual ~CMainWindow();
       // Enable a table driven WndProc.
       BEGIN_MSG_MAP(CMainWindow)
           MESSAGE_HANDLER(WM_PAINT, OnPaint)
           MESSAGE_HANDLER(WM_MOUSEMOVE,OnMouseMove)
           MESSAGE_HANDLER(WM_SETFOCUS,OnSetFocus)
           MESSAGE_HANDLER(WM_KILLFOCUS,OnKillFocus)
           MESSAGE_HANDLER(WM_CREATE,OnCreate)
           MESSAGE_HANDLER(WM_WINDOWPOSCHANGING, OnWindowPosChanging)
       END_MSG_MAP()
         LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled);
         LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled);
         LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled);
         LRESULT OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled);
         LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled);
         LRESULT OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled);
  
  
  private:
      CAxWindow m_wndIE;
      RECT m_Rect;
  };
  LRESULT CMainWindow ::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled)
  {
      WINDOWPOS* pwp= (WINDOWPOS*)lParam;
      if (pwp)
      {
          m_wndIE.SetWindowPos(NULL, pwp-&gt;x, pwp-&gt;y, pwp-&gt;cx, pwp-&gt;cy, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER |SWP_NOCOPYBITS);
      }
  
      bHandled= FALSE;
      return 0;
  }
  
  LRESULT CMainWindow::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled)
  {
      m_wndIE.Create(m_hWnd, m_Rect, NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP |WS_BORDER);
      m_wndIE.CreateControl(L"{8856F961-340A-11D0-A96B-00C04FD705A2}", NULL, NULL);
  
  
      bHandled = false;
      return 0;
  }
  
  // Paint some centered text into the client area.
  LRESULT CMainWindow:: OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled)
  {
  
      bHandled = false;
      return 0;
  }
  // Paint some centered text into the client area.
  LRESULT CMainWindow:: OnKillFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled)
  {
  
      bHandled = false;
      return 0;
  }
  // Paint some centered text into the client area.
  LRESULT CMainWindow:: OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled)
  {
      //MessageBox("OnMouseMove","",MB_OK);
      bHandled = false;
      return 0;
  }
  
  // Paint some centered text into the client area.
  LRESULT CMainWindow:: OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&amp; bHandled)
  {
       // This example makes use of a number of Win32 API calls.
       // See online help (if necessary).
       PAINTSTRUCT ps;
       BeginPaint(&amp;ps);
       HDC hDC = GetDC();
       RECT r;
       GetClientRect(&amp;r);
       DrawText(hDC, "My ATL Window", -1, &amp;r, DT_SINGLELINE |
               DT_VCENTER | DT_CENTER);
       EndPaint(&amp;ps);
       ReleaseDC(hDC);
       return 0;
  }
  
  // Create and destroy this window.
  CMainWindow::CMainWindow(const RECT rect)
  {
      CopyRect(&amp;m_Rect,&amp;rect);
   //    // Create my window.
      //RECT rc= {10, 10, 200, 200};
   //    Create(NULL, rc, "My ATL Window");
   //    ShowWindow(SW_SHOWNORMAL);
  }
  
  
  CMainWindow::~CMainWindow()
  {
      /* if(m_hWnd)
            DestroyWindow();*/
  }
  //CMainWindow theWind;
  
  int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
                  PSTR szCommand, int iShow)
  {
      _Module.Init(NULL,hInst);
      RECT rect={ 200,200,300,300};
      CMainWindow mw(rect);
      mw.Create(NULL,rect,_T("MyWindow"),
          WS_OVERLAPPEDWINDOW | WS_VISIBLE);
  
      MSG msg;
      while(GetMessage(&amp;msg,NULL,0,0))
      {
          TranslateMessage(&amp;msg);
          DispatchMessage(&amp;msg);
      }
  
  
      _Module.Term();
  return 0;
  }
  </code></pre>