title: Setting the Position of an MFC Dialog
body: <p>I need to set the position of an <code>MFC Dialog</code> to some <code>relative position</code> (Upper Right Corner) to it's parent dialog. I am using the following code:</p>
  
  <p><strong>MainFrame.h:</strong></p>
  
  <pre><code>/*Creation of Dialog*/
  SearchCommands* searchDialog;
  </code></pre>
  
  <p><strong>MainFrame.cpp:</strong></p>
  
  <pre><code>/*In Constructor*/
  searchDialog = new SearchCommands();
  
  /*In an Init Method*/
  if (!searchDialog-&gt;Create(IDD_COMMANDS_SEARCH, this))
  {
      TRACE0("Failed to create Search Dialog\n");
      delete searchDialog;
  }
  
  /*Button Click Event*/
  void CMainFrame::OnSearchButton()
  {
      /*Get the ordinates of parent*/
      RECT rect;
      CWnd::GetWindowRect(&amp;rect);
  
     /*searchDialog is the pointer to a dynamically created Dialog*/
     searchDialog-&gt;SetWindowPos(&amp;CWnd::wndNoTopMost,rect.left,rect.bottom,rect.left,rect.bottom,SWP_SHOWWINDOW );
  
     searchDialog-&gt;ShowWindow(SW_SHOWNORMAL);
  }
  </code></pre>
  
  <p>But the Dialog disappears instead of being shown properly. I could not understand <em>how the parameters should be passed to <a href="https://msdn.microsoft.com/en-us/library/a1yzfz6d.aspx" rel="nofollow"><code>CWnd::SetWindowPos</code></a> method</em> so may be I am doing something wrong there.  </p>
  
  <p>Any guidance will be appreciated.</p>