_ Property TBitmap * Bitmap = {read = GetBitmap, write = SetBitmap}; _ property usage

Source: Internet
Author: User

_ Property TBitmap * Bitmap = {read = GetBitmap, write = SetBitmap}; </p> <p> defines a Property for a Class ), there are two types of attribute operations: Get or Read, Set or Write, these operations are declared in braces ('{' & '}') after the equal sign (=. Read indicates the read operation, write indicates the operation to set this attribute, separated by the equal sign (=), followed by the data variables and processes to be operated (the process is set and the return value is void, contains at least one parameter. The parameter type is the type of the attribute.) or a function (corresponding to a read operation, the returned value is the data type of the attribute, and the parameter is zero or multiple ). You can also add a default value (nodefault or default = DefaultInitializeValue) to the Property editor. The default value is usually a constant value. If you do not know whether to use the function, refer to the relevant documentation ). </P> <p> example: <br/> class TA: public TParentClass <br/>{< br/> private: <br/> int FLeft; <br/> // attribute data storage variables are stored in private domains. <br/> // This can protect data, <br/> // in this example, Left is an attribute. <br/> // After the Left value is changed, <br/> // The Position of the object. <br/> // The Position of the object must also be changed. <Br/> // when data is put into public, <br/> // The external object can directly return the value of the variable <br/> // the actual location of the object, <br/> // notification not changed (no notification portal) <br/> // not changed, this leads to attribute disorder <br/> // and put it in a private domain, <br/> // The external object cannot be operated directly </p> <p> void _ fastcall SetLeft (const int Value ); <br/> // a property interface is provided. <br/> // you can specify an attribute for external users, <br/> // The property interface sets up a process SetLeft for processing, <br/> // when modifying the Left attribute value, you must modify the actual position. <br/> protected: <br/> public: <br/> _ property int Left = {read = FLeft/* directly read the FLeft value in the private domain */, <br/> write = SetLeft/* sets FLeft through SetLeft */. <br/> default = 0/* the default Attribute Editor value is 0 */}; <br/>}; </p> <p> // SetLeft Process <br/> void _ fastcall TA: SetLeft (const int Value) <br/>{< br/> try <br/>{< br/> // change the actual location <br/> SetPosition (Value/* Left, -1 As NoChange */, <br/>-1/* Top,-1 As NoChange */, <br/>-1/* Width, -1 As NoChange */, <br/>-1/* Height,-1 As NoChange */); <br/>}< br/> catch (...) <br/>{< br/> // If location adjustment fails, the attribute Value is not changed <br/> return; <br/>}< br/> FLeft = Value; <br/>}

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.