Introduction to VCL Method

Source: Internet
Author: User

Introduction to VCL Method

1. Transform the Delphi object into a Windows window, mainly to set the handle and callback functions. After creating a Windows window, assigning its handle to the properties of the Delphi object is not difficult, which is equivalent to the Windows window that this Delphi control represents in the future, which is exactly what it contains. It is important to note that many of the parameters that are created by the Windows window are provided by the properties of the Delphi object, so creating the Windows window is just an intermediate process for the Delphi object and is not required.
2. The encapsulation of callback functions is clever, so that it can encapsulate a class of ordinary functions as a callback function. This kind of ordinary function also contains the class virtual function.
3. Since the callback function is encapsulated into a class function, in theory, as long as a class, even the image control class, you can have a callback function, and processing the message.
4. The graphics control class has the window function, in theory, can handle the message, but also must receive the message to handle AH. Windows does not send messages to Windows that do not have graphics controls, so what do you do, use Windows window as the host for these graphical controls, first the Windows window to collect messages, and then use a very critical message wm_ Nchittest to detect whether the location where the current message was generated falls within the bounds of an image control in the Windows window, and what the message is, knowing that it will be possible for the Windows control to be sent to the graphical control to execute itself.
It is because of the wm_nchittest message that it is possible to correctly differentiate and determine which image control is, and then to process the message. I've been thinking about what to do without the news, maybe there's no way. But where the mouse to go, even if nothing is clicked, the system is always aware of it, so the news is also inevitable. Without this message, it will also provide a function to continuously provide its location and related information.
5. After the message is issued, it must be delivered in the VCL framework to function correctly, here with the help of the Delphi compiler, plus two unique features, one is inherited, can call the parent class with the same name function processing the message, the other is the message index function, simplifies the message parameter settings, Once the message is issued, the compiler's dispatch guarantees that the object will receive this message directly.
6. VCL uses sandwich design techniques and so on, can do different performance and preparation work
7. In the VCL design process, a style is used, which means that the control has no ability to use state, which represents the current status of the control.
8. More uniquely, VCL defines two very simple classes Tgraphiccontrol and Tcustomcontrol, making it easy for third-party developers to develop controls, and can be automatically integrated into the IDE for ease of use
9. A set of VCL code can be run by the programmer at the same time and the use of the IDE, only a very small number of code needs to add judgment is in the reading and design state, it feels amazing

------------------------------------------------
If you want to understand the principle of VCL by learning to develop controls, you should learn some of the following typical controls:
1. Tlabel, simple image control, inherits from Tgraphiccontrol, can output text, see how it is redrawn after the partial area of its parent control is invalidated, so as to achieve the effect of the graphics control refreshing content
2. TButton, common button control, inherit from Twincontrol, and use the Superclass function wrapper button, mouse click the direction of the message is very important Ah, windows most of the functions are provided by the button
3. Tedit, common edit control, inherit from Twincontrol, and use the superclass function to wrap edit, the simplest input data place, see how to change its data
4. Tpanel, a great container, inherited from the Tcustomcontrol, its effect is self-painted, not Windows standard control, both a handle container control, but also self-contained, and canvas can be infinitely self-painted, unlimited potential. One of them inadvertently discovered that the main control of Quickreport actually inherited from it.
5. Tspeedbutton, is clearly a graphic control, inherited from the Tgraphiccontrol, but the appearance and use of the time, can not see the difference with the TButton, very special effect, almost genuine. Perhaps all Windows standard controls can be imitated and transcended using a similar approach.
6. Tsplitter, a great partition control, inherited from the Tgraphiccontrol, has my dream segmentation effect, but also can move the change
7. TTimer, a very simple and easy to use control, inherited from the tcomponent, encapsulated the Windows system clock function, perhaps most of the system's functions can be included in such a non-visual control
There are also some third-party beautiful controls, which are not listed here.

The control that you want to develop: transparent Tpanel, not dependent on the tedit,tcxdate of edit for the full year date.

I must resist not learning Firemonkey and other techniques, but concentrating on learning and mastering VCL, and doing a few general tool software.

------------------------------------------------
Note: Object Pascal does not have an industry standard, and Delphi can design its compilers arbitrarily, as long as it feels justified. The result of this compiler mate framework is that the VCL overall code looks very concise and compiles quickly. And unlike C + +, although the performance is strong, but too theoretical, and has a standard set, so what to achieve anything is cumbersome, the speed is extremely slow.

Introduction to VCL Method

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.