Board index » cppbuilder » Change other properties of a component while editing a particular property

Change other properties of a component while editing a particular property

Hi all,

How do modify a property that is not being currently edited from the current
property editor. I've seen it for example in the object inspector where a
new
value to the current property being edited results in another property being
changing.

Regards Farmer Jones

 

Re:Change other properties of a component while editing a particular property


Quote
Farmer Jones wrote:
> How do modify a property that is not being currently edited from
> the current property editor. I've seen it for example in the object
> inspector where a new value to the current property being edited
> results in another property being changing.

I've used the setter function for a particular property to change
another property because the options were mutually exclusive...

Re:Change other properties of a component while editing a particular property


Make sure the editor knows who the owner is (the component).  If you have a
pointer to the component then you can access any property you like.

An example from one of my property editors:

void __fastcall TLockEditorProperty::Edit()
{
bool Error = false;

try
 {
  TLockEditor *pEditor = reinterpret_cast<TLockEditor *>(GetOrdValue());
// link to component

  try
    {
    TWinAppLock *Lock = dynamic_cast<TWinAppLock*>(pEditor->Owner);
    if(Lock)
      {
      std::auto_ptr<TfrmWinAppLockEditor> frm(new TfrmWinAppLockEditor(0,
Lock));
      frm->ShowModal();
      }
    else
      Error = true;
    }

  catch(...)
    {
    Error = true;
    }

  }

catch(...)
 {
  Error = true;
  }

if(Error)
  AppMsg(MBM_ERRORCREATINGEDITOR,
         MBT_COMPONENTEDITOR,
         MB_OK+MB_ICONEXCLAMATION+MB_DEFBUTTON1+MB_APPLMODAL);

Quote
}

HTH

--
Malcolm Smith
MJ Freelancing
http://www.mjfreelancing.com
Software Protection for C++Builder

Quote
"Farmer Jones" <dsja...@ntlword.com> wrote in message

news:3d738eb9@newsgroups.borland.com...
Quote
> How do you call the setter function for another property from within
> the editor of a different property?

> Regards Farmer Jones

> "Fishface" <fishf...@drift.net> wrote in message
> news:3d738db8@newsgroups.borland.com...
> > Farmer Jones wrote:

> > > How do modify a property that is not being currently edited from
> > > the current property editor. I've seen it for example in the object
> > > inspector where a new value to the current property being edited
> > > results in another property being changing.

> > I've used the setter function for a particular property to change
> > another property because the options were mutually exclusive...

Re:Change other properties of a component while editing a particular property


Quote
Farmer Jones wrote:
> How do you call the setter function for another property
> from within the editor of a different property?

No, the setter function for the property you are setting
changes the other property.

TPropertyEditor has a GetComponent() that you could
probably use if you need to do it from the property editor.

Re:Change other properties of a component while editing a particular property


Having trouble following your example code.

Your property editor is clearly TLockEditorProperty. I guess TLockEditor
is the component name that is being edited, or is it? It would appear that
you are showing a form to edit more than one of the properties of the
component at a time?

What is TWinAppLock?

All I want to do is to be able to change any property of the component from
say the SetValue() or GetValue() member functions of the editor. The other
properties will then change when the current property is changed to a value
that requires another property value to change.

Regards Farmer Jones

Re:Change other properties of a component while editing a particular property


TWinAppLock is a component from my security suite.

TLockEditorProperty is a property editor for a property called "Editor" (bad
choice for an example I guess) descending from TPropertyEditor.  This is
registered as:

    RegisterPropertyEditor(__typeinfo(TLockEditor),  __classid(TWinAppLock),
"Editor", __classid(TLockEditorProperty));

The property "Editor" has a property called "Owner" and this is the
TWinAppLock component itself.

The Edit() method for the editor class is (snipped):

void __fastcall TLockEditorProperty::Edit()
{
  TLockEditor *pEditor = reinterpret_cast<TLockEditor *>(GetOrdValue());
// link to component

    TWinAppLock *Lock = dynamic_cast<TWinAppLock*>(pEditor->Owner);
    if(Lock)
      {
      std::auto_ptr<TfrmWinAppLockEditor> frm(new TfrmWinAppLockEditor(0,
Lock));
      frm->ShowModal();
      }

Quote
}

The form now has a pointer to the main component and so ANY of the
properties can be changed.  In this example "Editor" is the same as the main
component editor - I just decided to make an option available from the
object inspector.

HTH

--
Malcolm Smith
MJ Freelancing
http://www.mjfreelancing.com
Software Protection for C++Builder

Quote
"Farmer Jones" <dsja...@ntlword.com> wrote in message

news:3d7396ca$1@newsgroups.borland.com...
Quote
> Malcolm,

> Having trouble following your example code.

> Your property editor is clearly TLockEditorProperty. I guess TLockEditor
> is the component name that is being edited, or is it? It would appear that
> you are showing a form to edit more than one of the properties of the
> component at a time?

> What is TWinAppLock?

> All I want to do is to be able to change any property of the component
from
> say the SetValue() or GetValue() member functions of the editor. The other
> properties will then change when the current property is changed to a
value
> that requires another property value to change.

> Regards Farmer Jones

Other Threads