In-depth C + + Builder writing their own components-in-depth analysis of VCL inheritance, message mechanism (1)

Source: Internet
Author: User
Tags inheritance join

This article refers to the content may have been seen in many places, the author is the same, but also read a lot of VCL source code, coupled with their actual experience in writing components, pieced together such an article. Therefore, all statements are personal views, experience of the description, for reference only.

You may reprint, copy, but must join the author's signature Aweay, if used for commercial purposes, must be approved by the author.

System Requirements

If you want to do it together, then you should take a look here, or you can skip directly.

C + + Builder6 + UPDATA4 (God made human tools, hereinafter referred to as BCB)

WINDOWS2K or higher (necessary)

The authors strongly recommend that you use WINNT,BCB to have a very large number of problems under Win9x, and that you are very unstable, even if you don't care about this, there is a very fatal problem, BCB Help files are not fully displayed under Win9x (because the number of BCB Help index keywords exceeds the Win9x limit), It's very difficult to refer to help.

Delphi6:( Necessary

What the? is not written wrong, completely did not write wrong, if you want to go deep vcl View source code, in no more suitable than with DELPHI6, after all installed Delphi6, the VCL source directory into the search path, so you can hold the CTRL key in the editor, Click the mouse to jump directly to the source code is very convenient, more useful than what grep.

Start

For the VCL message mechanism, you can refer to the Cker

http://www.csdn.net/develop/read_article.asp?id=8131

Repeat the content I do not introduce, but for writing components, the message mechanism is still very vague, and many times not to use those methods to deal with the message, there is a component-specific CM_XXXXXXXX message how to deal with it? How do you join your own events? I'll cover these questions in more detail later in the discussion.

Standing on the shoulders of giants

The first thing to write a component is to determine the problem we inherit from there, and choosing a good ancestor class is the first step in writing a good component, so how do you choose the stone of his mountain? The general rule is this:

1. For an interface display, a component that needs to handle keyboard events and is not a container inherits from Tcustomcontrol

2. For the interface display, need not handle keyboard events, need to handle mouse events from the Tgraphicscontrol inheritance

3. Controls similar to Topendialog/txpmenu are inherited from Tcomponent for the display of No interface

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.