Enumerate the use of top-level window functions enumwindows and its callback functions!

Source: Internet
Author: User

First, its prototype
Bool enumwindows (
Wndenumproc lpenumfunc, // address of the callback function -- to put it bluntly, the callback function name is put in this
Lparam // if it is used to enumerate all windows on the desktop, add 0 or null.
);
Let's take a look at the callback function prototype.
Bool callback enumwindowsproc (
Hwnd, // handle parameter. Here the returned window handle is
Lparam // application-defined value -- I don't know what it means.
);
When using the callback function, you must write the prototype above. The name of the enumwindowsproc function must be the same.
Just start it, for example: bool callback ABCD (hwnd, lparam); remove ";" from the function body. The function body is what you want to execute. Code For example:
Bool callback ABCD (hwnd, lparam)
{
Cstring text;
Int Len =: getwindowtextlength (hwnd); // obtain the title length pointed to by the window handle hwnd.
: Getwindowtext (hwnd, (lpstr) (lpctstr) text, Len + 1); get the title of the window pointed to by the window handle hwnd
M_list.addstring (lpstr) (lpctstr) text); // m_list is the clistbox m_list pointing to the list box.
Return 1; // 1 must be returned here. If 0 is returned, it is not enumerated.
}

 

 

Example:

 

 

bool callback myenumproc (hwnd, lparam)
{< br> printf ("the window handle is % x, and the passed parameter is % d", hwnd, lparam);
}< br> main
{< br> int n = 3; // any parameter
enumwindows (myenumproc, (lparam) n);
...
}

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.