Some issues when creating custom VCL components using C ++ Builder

zhaozj2021-02-08  247

Home: http://www.maxss.net email: maxchou@163.com

In some cases, due to special needs, we need to develop its own VCL components to meet demand. Some problems for beginners is to emphasize. First: is the name of the name of the file and class, "Component-> New Component ...", enter your class name in the "Unit File Name" column of the "New Component" dialog, such as your class Name "TMYCLASS", then fill in "MyClass" here, note that "T" is not added here. This file will be opened after confirmation. After completing the editing of the source file and saves, you must install the component to the IDE environment, the operations are as follows: "Component-> Install Component ...", select the "INTO New Package" page, enter in "Unit File Name" The component source file path and file name to be installed, enter the new package file path and file name you want to generate in "Package File Name", pay attention to the name of the package you should be class, such as "TMYCLASS.BPK", so If the .bpk package file and the package source file "TMYCLASS.CPP", if you write myclass.bpk, your component's source file will be overwritten, of course you can choose to deposit in different paths. But this will not be easily managed and confusing. Second: How to customize the icon to the new component to select a suitable icon for the components written for yourself, express the components' functionality, this icon is the component bar in the design phase in the RAD environment. Displayed, generally size of 24x24. First, open the image editor of C Builder, select "File-> New ...-> Component Resource File (.dcr)", then select "Resource-> Bitmap", enter size and color data, confirm Just create a bitmap to edit, the default resource name is "Bitmap1", you should change this name, consistent with your .bpl file name, such as the.bpl "TMYComponent.bpl", Its name should be "TMYComponent" and is capitalized. Double-click the node to start editing your icon, of course, you can also use the "Paste" command to paste and pay attention to 256 colors. When the icon painting is completed, you can store it. You must pay attention to your named problem. This file name must be the same as your component class name. If your component class name is "MyComponent", the file name should be "Mycomponent.dcr). "And all uppercase. After installing your components again, you can use your own icon. This is the practice I created a custom component. If I have any incorrect places, please point out that you can learn from each other.

转载请注明原文地址:https://www.9cbs.com/read-2154.html

New Post(0)