Windows API Programming----The use of the EnumWindows () function

Source: Internet
Author: User

1.

Function Prototypes:

BOOL WINAPI EnumWindows (
_in_ Wndenumproc Lpenumfunc,
_in_ LPARAM LPARAM
);

Lpenumfunc: Pointer to application-defined callback function

LParam: application-defined value passed to the callback function

An explanation of EnumWindows in MSDN:

Enumerates all top-level windows on the screens by passing the handle to each window, in turn, to an application-defined CA Llback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE.

That

Enumerates all the top-level windows on the screen, transferring the handles of these windows to an application-defined callback function in turn. The enumwindows will continue until all the top-level windows are enumerated, or the callback function returns FALSE.

2.

The definition of the Enumwindowsproc () function:

BOOL CALLBACK Enumwindowsproc (
_in_ HWND hwnd,
_in_ LPARAM LPARAM
);

HWND: Handle to the top-level window passed to the function during the enumeration of each top-level window while invoking the function

LParam: The second parameter of the EnumWindows () function.

Return Value:

Returns True if the EnumWindows () function continues to call the Enumwindowsproc () function in the system and returns false to stop the enumeration.

MSDN explained:

An application-defined callback function used with the EnumWindows or enumdesktopwindows function. It receives top-level window handles. The Wndenumproc type defines a pointer to this callback function. Enumwindowsproc is a placeholder for the application-defined function name

That

application-defined functions for the enumwindows () or Enumdesktopwindos () functions. Receives the top-level window handle. The Wndenumproc type defines a pointer to this callback function. Enumwindowsproc is a placeholder for an application-defined function name.

Application Examples:

The function of this code is to enumerate all of the current top-level window handles, and to specify a window handle that, if the top-level window handle enumerated to and the window handle passed to the Enumwindowsproc function is different, causes the top-level window to be enumerated to fail

//Customizing the structure bodytypedefstruct_dlong{long WParam; LONG LParam;} Stlong;//definition of callback functionBOOL CALLBACK Enumwindowsproc (HWND hwnd, LPARAM LPARAM) {Stlong*pdlong = (stlong*) LParam; BOOL benable= (BOOL) pdlong->LParam;if(hwnd! = (HWND) pdlong->WParam) EnableWindow (hwnd, benable);//if the top-level window handle that is currently enumerated is different from the extra information passed by the keynote function (Enumwindos function) to do the specified top-level window handle, then the related enable or enable deactivation operationreturnTRUE;} ... stlong Dlong;//additional information passed to the EnumwindowsprocDlong.lparam =(LPARAM) False;dlong.wparam=(WPARAM) hWnd; EnumWindows (Enumwindowsproc, (LONG)&dlong);

Windows API Programming----The use of the EnumWindows () function

Related Article

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.