FindWindow function uses and FindWindowEx

(The FindWindow 
  the lpClassName,         {window class name} 
  lpWindowName: the PChar {title of the window} 
): the HWND;               {return window handle;} else return 0 

// the FindWindow FindWindowEx than two handles extra parameters: 
FindWindowEx ( 
  the Parent: the HWND;      to find the child {parent window handle} 
  child: the HWND;       {sub-window handle} 
  ClassName: the PChar; {} 
  WindowName: the PChar {} 
): the HWND; { 
if parent is 0, then the parent desktop window function to the window, find All child windows of the desktop window; 
if it is HWND_MESSAGE, only to find all function message window; 
child window must be a direct child window Parent window; 
if child is 0, starting from the first child to find the window Parent; 
if Parent and child at the same time is 0, the function to find all the top-level window, and message window. 
}

Function prototype: HWND FindWindowEx (HWND hwndParent, HWND hwndChildAfter, lpszClass LPCTSTR, LPCTSTR lpszWindow)
 hwndParent: To find the parent window handle of the child window.

    If hwnjParent is NULL, the desktop window function to the parent window, find the desktop window of all child windows.

    Windows NT5.0 and later: If hwndParent is HWND_MESSAGE, only to find all function message window.

    hwndChildAfter: child window handle. Find begin from the next child window in the Z order. Child window must be window rather than as a direct descendant child window hwndPareRt window. If HwndChildAfter is NULL, starting from the first child to find the window hwndParent. If hwndParent and hwndChildAfter the same time is NULL, the function looks for all top-level window and the message window.

    lpszClass: specifies the class name points to a null-terminated string, or a member of a class name identification string pointer. If this parameter is a member, then it must be a previous member theGlobaIAddAtom call the global function generated. The member is 16, must be in the low 16's lpClassName, high it must be zero.

    lpszWindow: point to a specified window name (the window title) null-terminated string. If this parameter is NULL, all window was the whole match. Return Value: If the function succeeds, the return value with the specified window handle and a window class name name. If the function fails, the return value is NULL.

Use Example. 1:
IntPtr = ptrResult the FindWindow (null, "Test");
IntPtr ptrRadioButtonbox = FindWindowEx (ptrResult, IntPtr.Zero , "Button", "& 8 bit");
IntPtr = ptrStartBtn the FindWindowEx (ptrResult, IntPtr.Zero, null, "OK");
Use Example 2:
BM_CLICK = 0xF5 int const; 
IntPtr maindHwnd = FindWindow (null, "QQ user login"); // get a handle QQ login box 
IF (! maindHwnd = IntPtr.Zero) 
{ 
    IntPtr childHwnd = FindWindowEx (maindHwnd, IntPtr.Zero, null "login"); // get the handle of a button 
    IF (childHwnd = IntPtr.Zero)! 
    { 
        SendMessage (childHwnd, BM_CLICK, 0, 0); // click the button to send a message 
    } 
    the else 
    { 
        MessageBox.Show ( "not found sub-window "); 
    } 
} 
the else 
{ 
    MessageBox.Show (" window not found "); 
}
 

  

 

Guess you like

Origin www.cnblogs.com/marszhw/p/11087886.html