
#DELPHI GETWINDOWTEXT NEVER WORKS WINDOWS#
The function of the EnumWindows function is to enumerate the top-level windows in all the programs on the screen and pass the window handle to the callback function as an argument. Here is the format for calling EnumWindows:īy registering the entry address of the callback function with the system, the system can invoke the callback function when needed, passing parameters to it, perhaps these parameters are what we want. The Lpenumfunc is the entry address of the callback function.

Tfnwndenumproc is actually a pointer type. Then look at the function that registers the entry address of the callback function to the caller.įunction EnumWindows (lpenumfunc:tfnwndenumproc LParam:LPARAM): BOOL stdcall Writing function body is very simple, using the parameters passed over it, just remember that these parameters are sent to you, you just know what these parameters mean. StdCall is a standard call, which means calling a function with standard Windows parameter passing. Note that you must take "stdcall" in the back. are stipulated, because these are to let other programs call, they have been prescribed, but the parameter name can be arbitrarily called. Some Windows API functions require a callback function address as one of its parameters, such as SetTimer, LineDDA, EnumObjects, and the enumwindows we want to use below.ĭeclaring a callback function in Delphi is a simple format, for example:įunction Enumwindowsproc (ahwnd:longint lparam:longint): Boolean stdcall įirst of all, the function name can be arbitrarily random, but the type of function parameters generally not disorderly, its order, data type, etc.

So after a callback function is written out, there must be a registered action that tells the caller how you found the function I wrote.

So a lot of people say that the callback function is a bit like the BP machine you're carrying: Tell someone the number and call you when it's something! The callback function typically defines the type of parameters and return values as required by the caller, you provide the caller with the entry address of your callback function, and then you can call the function to notify you at any time when the caller has an event, and pass the parameters in a predetermined form. The callback function is written out not by its own program to invoke, but to let other things to invoke, such as the Windows operating system, such as other programs and so on. Using my method to control the window controls on other programs ' forms, you must first understand what isĬallback function。 My understanding is this: Delphi finds a window handle with a title known to traverse the window control handle (GO)
