Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual C++
Reference
Libraries Reference
MFC
Classes
CWnd Class
Member Functions
 CWnd::FindWindow

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
MFC Library Reference 
CWnd::FindWindow 

Returns the top-level CWnd whose window class is given by lpszClassName and whose window name, or title, is given by lpszWindowName.

static CWnd* PASCAL FindWindow(
   LPCTSTR lpszClassName,
   LPCTSTR lpszWindowName 
);

Parameters

lpszClassName

Points to a null-terminated string that specifies the window's class name (a WNDCLASS structure). If lpClassName is NULL, all class names match.

lpszWindowName

Points to a null-terminated string that specifies the window name (the window's title). If lpWindowName is NULL, all window names match.

Identifies the window that has the specified class name and window name. It is NULL if no such window is found.

The CWnd* may be temporary and should not be stored for later use.

This function does not search child windows.

// activate an application with a window with a specific class name
      BOOL COneT32App::FirstInstance()
      {
         CWnd *pWndPrev, *pWndChild;

         // Determine if a window with the class name exists...
         if (pWndPrev = CWnd::FindWindow(_T("MyNewClass"),NULL))
         {
            // If so, does it have any popups?
            pWndChild = pWndPrev->GetLastActivePopup();

            // If iconic, restore the main window
            if (pWndPrev->IsIconic())
               pWndPrev->ShowWindow(SW_RESTORE);

            // Bring the main window or its popup to the foreground
            pWndChild->SetForegroundWindow();

            // and you are done activating the other application
            return FALSE;
         }
      }
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker