How to control window controls on other program forms:
First, I declare that I am a cainiao. I just want to publish a solution to the problem that has been around me for a long time, so that I will not forget it in the future, at the same time, it provides some help to colleagues who do not know this little knowledge. Don't laugh at me. At the same time, in order to express my low level, I will talk about some basic things, which are my understanding and inaccurate.
To control window controls on other program forms, you must first understand what callback functions are. My understanding is as follows:
The callback function is not called by your own program. Instead, you can call other things, such as windows operating systems and other programs. But I don't know when to call it. The callback function defines the type of parameters and return values according to the caller's requirements. You provide the caller with the entry address of your callback function, then, when an event occurs, the caller can call this function at any time according to the address you provided, and PASS Parameters in a pre-defined form. For example, the callback function is a bit like the bpserver you bring with you: tell someone else the number and Call you when something happens!
So after a callback function is written, there must be a registration action to tell the caller how to find the function I wrote. Some Windows API functions require the callback function address as one of their parameters, such as SetTimer, LineDDA, EnumObjects, And the EnumWindows we will use below.
The format of declaring a callback function in Delphi is very simple, for example:
Function EnumWindowsProc (AhWnd: LongInt; lParam: LongInt): boolean; stdcall;
First, the function name can be randomly obtained, but the type of function parameters should not be in disorder. The order and data type are specified, because these are called by other programs, they have already specified this, but the parameter names can be randomly called. Note that "stdcall" must be included later ",
Stdcall is a standard call, that is, a function is called by passing standard windows parameters.
Writing the function body is simple. You can use the passed parameters. Remember that these parameters are sent to you by someone else. You only need to know what these parameters mean.
Let's look at a function that registers the callback function entry address with the caller.
Function EnumWindows (lpEnumFunc: TFNWndEnumProc; lParam: LPARAM): BOOL; stdcall;