Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7751109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:27:49+00:00 2026-06-01T11:27:49+00:00

I am writing my custom visual component and find it convenient to publish some

  • 0

I am writing my custom visual component and find it convenient to publish some of its properties as array:

class PACKAGE TVctDiag2 : public TCustomControl
{
__published:
    __property int ArrowStyle[int index] = {read=GetArrowStyle,write=SetArrowStyle};
protected:
    void __fastcall SetArrowStyle(int index, int value);
    int __fastcall GetArrowStyle(int index);
...
};

Component is built and installed without problems. But after I try to insert component on form, access violation message box shows. When debugging source of error I found, that method GetArrowStyle is called with index value of -1 which causes reading out of array bounds. I understand that user of TVctDiag2 class (=integrated development environment) cannot know what is the array size. The size of array is constant and its quite a small number (6), so alternative solution would be:

class PACKAGE TVctDiag2 : public TCustomControl
{
__published:
    __property int ArrowStyle1 = {read=GetArrowStyle1,write=SetArrowStyle1};
    __property int ArrowStyle2 = {read=GetArrowStyle2,write=SetArrowStyle2};
    __property int ArrowStyle3 = {read=GetArrowStyle3,write=SetArrowStyle3};
    __property int ArrowStyle4 = {read=GetArrowStyle4,write=SetArrowStyle4};
    __property int ArrowStyle5 = {read=GetArrowStyle5,write=SetArrowStyle5};
    __property int ArrowStyle6 = {read=GetArrowStyle6,write=SetArrowStyle6};
protected:
    void __fastcall SetArrowStyle1(int index, int value);
    int __fastcall GetArrowStyle1(int index);
    void __fastcall SetArrowStyle2(int index, int value);
    int __fastcall GetArrowStyle2(int index);
    void __fastcall SetArrowStyle3(int index, int value);
    int __fastcall GetArrowStyle3(int index);
    void __fastcall SetArrowStyle4(int index, int value);
    int __fastcall GetArrowStyle4(int index);
    void __fastcall SetArrowStyle5(int index, int value);
    int __fastcall GetArrowStyle5(int index);
    void __fastcall SetArrowStyle6(int index, int value);
    int __fastcall GetArrowStyle6(int index);
...
};

But I prefer more general solution. How can this be accomplished, if possible with option to change property values through Object inspector.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:27:50+00:00Added an answer on June 1, 2026 at 11:27 am

    Declare array properties as public instead. __published is used for design-time editing and RTTI generation, which do not support array properties:

    class PACKAGE TVctDiag2 : public TCustomControl
    {
    public:
        __property int ArrowStyle[int index] = {read=GetArrowStyle,write=SetArrowStyle};
    protected:
        void __fastcall SetArrowStyle(int index, int value);
        int __fastcall GetArrowStyle(int index);
    ...
    };
    

    Your second example is buggy. You need to remove the index parameters from the getter/setter methods since the properties does not use indexes (by using non-array properties, you can declare them as __published):

    class PACKAGE TVctDiag2 : public TCustomControl
    {
    __published:
        __property int ArrowStyle1 = {read=GetArrowStyle1,write=SetArrowStyle1};
        __property int ArrowStyle2 = {read=GetArrowStyle2,write=SetArrowStyle2};
        __property int ArrowStyle3 = {read=GetArrowStyle3,write=SetArrowStyle3};
        __property int ArrowStyle4 = {read=GetArrowStyle4,write=SetArrowStyle4};
        __property int ArrowStyle5 = {read=GetArrowStyle5,write=SetArrowStyle5};
        __property int ArrowStyle6 = {read=GetArrowStyle6,write=SetArrowStyle6};
    protected:
        void __fastcall SetArrowStyle1(int value);
        int __fastcall GetArrowStyle1();
        void __fastcall SetArrowStyle2(int value);
        int __fastcall GetArrowStyle2();
        void __fastcall SetArrowStyle3(int value);
        int __fastcall GetArrowStyle3();
        void __fastcall SetArrowStyle4(int value);
        int __fastcall GetArrowStyle4();
        void __fastcall SetArrowStyle5(int value);
        int __fastcall GetArrowStyle5();
        void __fastcall SetArrowStyle6(int value);
        int __fastcall GetArrowStyle6();
    ...
    };
    

    If you want to use separate properties for the individual array values, I would suggest going back to using indexes with a single set of getter/setter methods by using the index specifier on the property declarations (I would even go as far as declaring a public array property again for good measure, in case you ever need to loop through the values in code):

    class PACKAGE TVctDiag2 : public TCustomControl
    {
    __published:
        __property int ArrowStyle1 = {read=GetArrowStyle,write=SetArrowStyle,index=0};
        __property int ArrowStyle2 = {read=GetArrowStyle,write=SetArrowStyle,index=1};
        __property int ArrowStyle3 = {read=GetArrowStyle,write=SetArrowStyle,index=2};
        __property int ArrowStyle4 = {read=GetArrowStyle,write=SetArrowStyle,index=3};
        __property int ArrowStyle5 = {read=GetArrowStyle,write=SetArrowStyle,index=4};
        __property int ArrowStyle6 = {read=GetArrowStyle,write=SetArrowStyle,index=5};
    public:
        __property int ArrowStyle[int index] = {read=GetArrowStyle,write=SetArrowStyle};
    protected:
        void __fastcall SetArrowStyle(int index, int value);
        int __fastcall GetArrowStyle(int index);
    ...
    };
    

    If you want design-time editing of an array, you either need to write a custom component editor and register it with the IDE, or re-write the array property into a TCollection (which is fully supported in RTTI and design-time editing).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some thoughts about writing custom html helpers. In our project everywhere you can find
We're writing a custom subclass of TextBox where we need to change only some
I'm writing a custom file selection component. In my UI, first the user clicks
I'm writing a custom swing component (something completely new, but think JTree or JList).
I'm writing custom ActionFilterAttribute and trying to write some data directly into output stream
As part of writing custom command (COM-Visible dll with class that implements Interwoven command
Im writing custom docs for some java methods, and some of them are overloaded
During uninstallation of the Visual Studio Integration Package that I am writing, I need
I am looking for a solution for reading (and possibly writing) custom properties of
I'm writing a custom ATL ActiveX component, but I'm having this little weeny problem:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.