Usage of findwindow (API)

Source: Internet
Author: User

 

The findwindow function retrieves a handle to the top-level window whose class name and window name match

Specified strings. This function does not search child windows. This function does not perform a case-sensitive

Search.
The findwindow function searches for the parent form based on the given form class name and form name string and returns its form handle. This function does not search for subforms. This function is not

Completes an event-aware search.

To search child windows, beginning with a specified child window, use the find=wex function.
To search for the child form of the given form, use the findwindowex function.

Syntax
Syntax

Hwnd findwindow (
Maid,
Lptstr lpwindowname
);

Parameters
Parameters

Lpclassname
[In] pointer to a null-terminated string that specifies the class name or a class atom created by a previous call

The registerclass or registerclassex function. The atom must be in the low-order word of lpclassname; the high-order

Word must be zero.
[Input] A string pointer with zero as the Terminator. It specifies the Class Name of the form or class atom created by the previously executed registerclass or registerclassex function.

The two low-level atomic bytes must be the lpclassname parameter, and the two high-level bytes must be zero.

If lpclassname points to a string, it specifies the window class name. The class name can be any name registered

With registerclass or registerclassex, or any of the predefined control-class names.
If the lpclassname Pointer Points to a string, it gives the Class Name of the form. The class name can be any name registered by registerclass or registerclassex, or

Is the name of any predefined control class.

If lpclassname is null, it finds any window whose title matches the lpwindowname parameter.
If the lpclassname is a null pointer, the function searches for all forms based on the lpwindowname parameter.

Lpwindowname
[In] pointer to a null-terminated string that specifies the window name (the window's title). If this parameter is

Null, all window names match.
[Input] A string pointer with zero as the Terminator. The name (title) of the form is given ). If this parameter is a null pointer, the form name is ignored during function search.

Return Value
Function return value

If the function succeeds, the return value is a handle to the window that has the specified class name and window

Name.
If the function is successfully executed, the return value is the form handle of the given form class name and form name.

If the function fails, the return value is null. To get extended error information, call getlasterror.
If the function fails to be executed, the return value is zero. Run the getlasterror function to obtain more error information.

 

After reading msdn, you can see that this function is used to find the parent form handle.
For example, for the IE browser form of your post, its form class name is "ieframe", and the form name is "Baidu _ VB _ ask the specific usage of findwindow (API! -Microsoft Internet Explorer ".
So now the handle of this form is obtained as follows:

Hwnd = findwindow ("ieframe", "Baidu _ VB _ I would like to ask the specific usage of findwindow (API! -Microsoft Internet Explorer ")

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.