Define the implementation method of the event in C ++ Builder.

Source: Internet
Author: User

Define the implementation method of the event in C ++ Builder.

++ Builder is a visual integrated development tool launched by Borland. C ++ Builder's integrated development environment (IDE) provides a series of visual and Rapid Application Development (RAD) tools, allowing programmers to easily create and manage their own programs and resources. Now let's take a look at the implementation method for defining events in C ++ Builder.

I. Events

Do you know how an event exists in C ++ Builder? In fact, events are a delegated model, which encapsulates messages. Let us assume that you have used C ++ development tools of Microsoft Company VC (MicrosoftVisualC ++ (Visual C ++, MSVC, VC ++ or VC for short, with an integrated development environment, you can edit C, C ++, C ++, CLI, and other programming languages .) You should know that there are no events in Visual C ++. Some are only message processing functions. However, in C ++ Builder, event processing functions are used to respond to messages.

In addition, the event itself is also a pointer, which is a closure. Generally, there are two types of events in C ++ Builder. These two types of events are custom events and notification events (that is, the tpolicyevent pointer, which encapsulates Windows messages ). On the other hand, I believe everyone should know that events are ignited by a virtual function. The ONEXIT event is ignited by the DOEXIT virtual function. To facilitate your understanding, I will compile a demo about custom events here. One of the most important things you need to know about custom events is that your code will certainly lead to these events. These events do not automatically occur in response to user or system actions, and even code that can be written to make the event happen in this way is no exception. If you want to know about notification-type events, you can search for information on the Internet.

Ii. Example

Specific programming code for custom events ,:

After reading the above programming code, we can see that the event in the Code Compiled by xiaobian is the encapsulation of the WM_MYMESSAGE message. In the above source code, you should be able to see an ONMYEVENT event in OBJECTINSPECTOR. This event is actually exactly the same as other events. All you need to do is write the programming code here to complete the Response Message. In addition, you can also give the behavior when this event is triggered based on application requirements. Well, the above programming code is a little simple. After all, it is just compiled by a small Editor. If you are interested, you can adjust it and compile a more perfect source code.

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.