Board index » delphi » Property Editor: error referencing a component in another module

Property Editor: error referencing a component in another module


2006-01-03 12:49:31 AM
delphi200
I'm writing a property editor that needs to reference a component located in
another module (Datamodule).
I'm using the Designer.GetComponent method and according to the
documentation as component name i'use something like
'MyDatamodule.MyComponent'.
The problem is the GetComponentMethod returns nil if the module was not
previously opened in the IDE.
To solve this problem I have used the IOTAModuleInfo.OpenModule method but i
still have an access violation the first time the component editor is
invoked.
The broblem seems to be that opening a module using OpenModule causes the
current component (and module) to loose the focus and then every call to the
property editor methods causes the access violation. The second time the
editor is invoked the all works fine.
The problem can be easilly reproduced (simple in a property editor open a
module using IOTAModuleInfo.OpenModule and then use the Designer property)
so i think I am doing something wrongs. Can everybody help me ?
TIA
sergio sette
 
 

Re:Property Editor: error referencing a component in another module

Sergio Sette writes:
Quote
The broblem seems to be that opening a module using OpenModule causes the
current component (and module) to loose the focus and then every call to the
property editor methods causes the access violation. The second time the
editor is invoked the all works fine.
I assume the IDE tries to destroy a property editor when the selection
changes, and this is why the methods then raise exceptions. I can not think
of a good workaround right now except for maybe having the property editor
be able to free itself, and then have some unrelated code open the unopened
data module and then re-invoke your property editor manually.
People have asked several times for the ability to open a file hidden in
the background, since the IDE allows this but the functionality is not
surfaced by the OTA. I don't remember this being in QC, but it might be
worth asking for there if it would help you in this case.
Erik