0

I have created a new VCL component based on an existing VCL component. What I want to do now is set the Password and Username properties from an ini file instead of the property inspector.

Robert Dunn Link

I read on the delphi forum above you cannot unpublish a property and that the only workaround is to redeclare the property as read-only. I tried this but it all it does is make the property read only and grayed out in the object inspector. While this could work I would prefer if the property wasn't visible at all.

__property System::UnicodeString Password = {read=FPassword};

Thanks in advance for any help or links to c++ VCL component writing tutorials. I am using CB2010

Gary Benade
  • 507
  • 4
  • 16

3 Answers3

2

Look up DesignIntf.UnlistPublishedProperty. See this tread.

JRL
  • 76,767
  • 18
  • 98
  • 146
0

The language as defined will not allow you to hide published properties.

I would make use of aggregation instead of inheritance i.e. Create a new VCL component that delegates its methods to the existing component, you then have full control over what properties to publish.

Hannes de Jager
  • 2,903
  • 6
  • 37
  • 57
0

I know this is an old question, but there is still no good documentation on how to do this. I ended up here myself trying to figure this out and thought that others ending up here for the same reason deserve an explanation on how to do this.

In the writing moment, I'm using C++ Builder 10.4 (Sydney).

There is a package called designide that you need to add as a reference to your project.

  1. In your package project, right click on "Requires" and select "Add Reference..."
  2. Click the "Browse" button and go to your install folder look for designide.bpi in lib\win32\release or lib\win64\release depending on your target.

The include path must also be updated so it can find the header file.

  1. Right click on your package project and select "Options"
  2. Select "Shared Options"
  3. For convenience, set "Target" to "All configurations - All platforms".
  4. Select "Include path" and click on the "..." to edit the value.
  5. Add the line $(BDSINCLUDE)\windows\vcl\design
  6. Click the Ok button and then save the changes.

In your code add #include <DesignIntf.hpp> and use the function UnlistPublishedProperty() to unpublish properties in your package function Register().

void __fastcall PACKAGE Register() {

    // Register components
    TComponentClass classes[1] = {__classid(TMyVCLClass)};
    RegisterComponents(L"MyComponent", classes, 0);

    // Unpublish properties
    UnlistPublishedProperty(__classid(TMyVCLClass),L"AlignWithMargins");
    UnlistPublishedProperty(__classid(TMyVCLClass),L"Margins");
}
Max Kielland
  • 5,627
  • 9
  • 60
  • 95