Although it is not. NET, it helps us understand callback: how to control the window controls on other program forms: On-Windows Development

Source: Internet
Author: User
Tags what callback

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;

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.