title: BringWindowToTop is Not working even if I get the handle to Class Window
body: <p>I am registering my Class in the following method:</p>
  
  <pre><code>BOOL CNDSClientDlg::InitInstance()
  {
      //Register Window Updated on 16th Nov 2010, @Subhen
      // Register our unique class name that we wish to use
      WNDCLASS wndcls;
      memset(&amp;wndcls, 0, sizeof(WNDCLASS));
  
      wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
      wndcls.lpfnWndProc  =  ::DefWindowProc; 
      wndcls.hInstance = AfxGetInstanceHandle();
      wndcls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
      wndcls.lpszMenuName = NULL;
  
      //Class name for using FindWindow later
      wndcls.lpszClassName = _T("CNDSClientDlg");
      // Register new class and exit if it fails
  
      if(!AfxRegisterClass(&amp;wndcls)) // [C]
  
      {
          return FALSE;
      }
  }
  </code></pre>
  
  <p>and then calling the InitInstance method and creating the window in constructor of the Class:</p>
  
  <pre><code>CNDSClientDlg::CNDSClientDlg(CWnd* pParent /*=NULL*/)
      : CDialog(CNDSClientDlg::IDD, pParent)
  
  {
  InitInstance();
  
      HWND hWnd;
      hInst = AfxGetInstanceHandle(); // Store instance handle in our global variable
      hWnd = CreateWindow(_T("CNDSClientDlg"), "NDS", WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);
  
  
  }
  </code></pre>
  
  <p>Now in my other application I am finding the window and trying to bring to top:</p>
  
  <p><strong>Edit</strong>
  Able to bring newlyCreated Windows with below code</p>
  
  <pre><code> CWnd *pWndPrev = NULL;
                      CWnd *FirstChildhWnd = NULL;
                      pWndPrev = CWnd::FindWindow(_T("CNDSClientDlg"),NULL);
                      if(pWndPrev != NULL)
                      {
                          //pWndPrev-&gt;BringWindowToTop();
                          WINDOWPLACEMENT wndplacement;
                          pWndPrev-&gt;GetWindowPlacement(&amp;wndplacement);
                          wndplacement.showCmd = SW_RESTORE;
                          pWndPrev-&gt;SetWindowPlacement(&amp;wndplacement);
                          pWndPrev-&gt;SetForegroundWindow();
  
                          FirstChildhWnd = pWndPrev-&gt;GetLastActivePopup();
                          if (pWndPrev != FirstChildhWnd)
                          {
                              // a pop-up window is active, bring it to the top too
                              FirstChildhWnd-&gt;GetWindowPlacement(&amp;wndplacement);
                              wndplacement.showCmd = SW_RESTORE;
                              FirstChildhWnd-&gt;SetWindowPlacement(&amp;wndplacement);
                              FirstChildhWnd-&gt;SetForegroundWindow();
                          }
  </code></pre>
  
  <p>I am able to find the window as <code>pWndPrev</code>  is not NULL , but It is not bringing up my application to front. Do I need to register any other class Instead of CNDSClientDlg. I want to bring my MFC application to top.</p>