Board index » cppbuilder » Component Editor problems

Component Editor problems


2005-03-30 04:03:35 AM
cppbuilder99
I am trying to build a custom component editor and am having some
problems with getting my code to build.
I've never done this before and have been fighting with it for 2 days
now and am stuck at this point.
What I am attempting to do is build a custom interface like TFont and a
few other properties use. I want to bring up my own created form and it
will allow me to set the properties within that instead of having
hundreds of standard properties.
I posted my code in the attachments group with the title "Component
Editor Attempt". This is all the code I have so far and it will not
compile I get the following 7 errors and am having problems getting by them.
Build
[C++ Error] GraphComponentEditor.h(20): E2113 Virtual function
'_fastcall TGraphComponentEditor::TGraphComponentEditor(TComponent
*,_di_IDesigner)' conflicts with base class 'TComponentEditor'
[C++ Error] GraphComponentEditor.cpp(9): E2316 'auto_ptr' is not a
member of 'std'
[C++ Error] GraphComponentEditor.cpp(9): E2108 Improper use of
typedef 'TfrmGraphEditor'
[C++ Error] GraphComponentEditor.cpp(9): E2188 Expression syntax
[C++ Error] GraphComponentEditor.cpp(10): E2247
'TfrmGraphEditor::FGraphComponentEditor' is not accessible
[C++ Error] GraphComponentEditor.cpp(10): E2031 Cannot cast from
'TComponent *' to 'TGraphComponentEditor *'
[Linker Fatal Error] Fatal: Unable to open file 'GRAPHEDITOR.OBJ'
I don't Register the Component Editor in this code yet. Could that be
one of my problems?
Any help so I can get pointed in the right direction would be greatly
appreciated. I have been getting mose of the design form the Builder
C++ Developers Guide if you are wondering.
thanks
shannon
 
 

Re:Component Editor problems

"SP" < XXXX@XXXXX.COM >wrote in message
Quote
[C++ Error] GraphComponentEditor.h(20): E2113 Virtual function
'_fastcall TGraphComponentEditor::TGraphComponentEditor(TComponent
*,_di_IDesigner)' conflicts with base class 'TComponentEditor'
Your constructor does not have the same signature as TComponentEditor's
constructor. Get rid of the 'inline' stuff.
Quote
[C++ Error] GraphComponentEditor.cpp(9): E2316 'auto_ptr'
is not a member of 'std'
You did not include auto_ptr's header file in your code:
#include <memory>
Quote
[C++ Error] GraphComponentEditor.cpp(10): E2247
'TfrmGraphEditor::FGraphComponentEditor' is not accessible
Your FGraphComponentEditor member is declared as 'private', thus nothing
outside of the TfrmGraphEditor class can access it. Since
TGraphComponentEditor is not declared as a 'friend' to TfrmGraphEditor,
TGraphComponentEditor cannot access TfrmGraphEditor's private data.
Quote
[C++ Error] GraphComponentEditor.cpp(10): E2031 Cannot
cast from 'TComponent *' to 'TGraphComponentEditor *'
You are supposed to be casting to the class type of the actual component
that is being edited. Do not cast to your editor class. Your dialog should
have no concept of the editor at all, only the component. Get rid of all
the editor stuff out of your dialog.
Quote
I don't Register the Component Editor in this code yet. Could
that be one of my problems?
No.
Gambit
 

Re:Component Editor problems

Deleted the inline stuff and tried to just compile that .ccp file to get
a obj but still get the same error. below is what the constructor looks
like now.
#pragma option push -w-inl
__fastcall virtual TGraphComponentEditor(Classes::TComponent*
AComponent, Designintf::_di_IDesigner ADesigner)
: TComponentEditor(AComponent, ADesigner)
{}
#pragma option pop
I also temporarily commented out the edit function so that this is the
only error occuring now.
Quote
>[C++ Error] GraphComponentEditor.h(20): E2113 Virtual function
>'_fastcall TGraphComponentEditor::TGraphComponentEditor(TComponent
>*,_di_IDesigner)' conflicts with base class 'TComponentEditor'


Your constructor does not have the same signature as TComponentEditor's
constructor. Get rid of the 'inline' stuff.


 

{smallsort}

Re:Component Editor problems

so you know it acts the same with the pragma lines taken out.
SP wrote:
Quote
Deleted the inline stuff and tried to just compile that .ccp file to get
a obj but still get the same error. below is what the constructor looks
like now.

#pragma option push -w-inl
__fastcall virtual TGraphComponentEditor(Classes::TComponent*
AComponent, Designintf::_di_IDesigner ADesigner)
: TComponentEditor(AComponent, ADesigner)
{}
#pragma option pop


I also temporarily commented out the edit function so that this is the
only error occuring now.

>>[C++ Error] GraphComponentEditor.h(20): E2113 Virtual function
>>'_fastcall TGraphComponentEditor::TGraphComponentEditor(TComponent
>>*,_di_IDesigner)' conflicts with base class 'TComponentEditor'
>
>
>
>Your constructor does not have the same signature as TComponentEditor's
>constructor. Get rid of the 'inline' stuff.
>
>

 

Re:Component Editor problems

I forgot to place a public before TComponent Class when deriving it.
I hate things like that.
SP wrote:
Quote
so you know it acts the same with the pragma lines taken out.

SP wrote:

>Deleted the inline stuff and tried to just compile that .ccp file to
>get a obj but still get the same error. below is what the constructor
>looks like now.
>
>#pragma option push -w-inl
>__fastcall virtual TGraphComponentEditor(Classes::TComponent*
>AComponent, Designintf::_di_IDesigner ADesigner)
>: TComponentEditor(AComponent, ADesigner)
>{}
>#pragma option pop
>
>
>I also temporarily commented out the edit function so that this is the
>only error occuring now.
>
>>>[C++ Error] GraphComponentEditor.h(20): E2113 Virtual function
>>>'_fastcall TGraphComponentEditor::TGraphComponentEditor(TComponent
>>>*,_di_IDesigner)' conflicts with base class 'TComponentEditor'
>>
>>
>>
>>
>>Your constructor does not have the same signature as TComponentEditor's
>>constructor. Get rid of the 'inline' stuff.
>>
>>
>
 

Re:Component Editor problems

OK I believe that I have the component editor classes built correctly
now. but I am not understanding how the Edit() function is going to get
called by clicking in the object inspector.
I'll place all my new code in the attachments newsgroup under the name
"Component Editor attempt 2".
Could someone take a look and tell me what I am doing wrong.
Thanks
Shannon
 

Re:Component Editor problems

Ok I got alot of what I want done working now but how can you set the
property to a string and make it static (always showing) like they did
for Font (TFont), Constraints (Constraints), etc...
I have overloaded the GetValue and SetValue functions but I can't seem
to get them to set the string. It only sets when I am focused on
editing that property. I basically returned the string in the GetValue
function, which is probably not the correct way to do it anyway.
thanks
Shannon
 

Re:Component Editor problems

"SP" < XXXX@XXXXX.COM >wrote in message
Quote
Ok I got alot of what I want done working now but how can
you set the property to a string and make it static (always
showing) like they did for Font (TFont), Constraints (Constraints),
etc...
Those kind of properties are based on classes. TFont and TSizeConstraints
both derive from TPersistent. The property editor is simply displaying the
class name.
Quote
I have overloaded the GetValue and SetValue functions but I
can't seem to get them to set the string. It only sets when I am
focused on editing that property. I basically returned the string
in the GetValue function, which is probably not the correct way
to do it anyway.
What EXACTLY are you trying to accomplish in the first place? What kind of
property are you editing? Please provide more details.
Gambit
 

Re:Component Editor problems

Remy Lebeau (TeamB) wrote:
Quote
What EXACTLY are you trying to accomplish in the first place? What kind of
property are you editing? Please provide more details.

I am just trying to make a design time property form for setting
properties pretaining to some graphing settings. If I just list all of
them in the Object Inspector there would be hundreds of Properties in
there and it makes the VCL component yucky to use. I believe doing it
this way will make the component alot more friendly for editing. I have
it working but I was just trying to get the class name to display like
TFont and TConstraints does, it's not important just wanted to make it
like the others.
As for the Property, I am creating an instance of TComponentProperty,
and if you click the ellipsis (...) it opens a form that has all the
settings pretaining to that group. The class name being display isn't a
big deal, I can live without that.
thanks for your help though
Shannon
 

Re:Component Editor problems

"SP" < XXXX@XXXXX.COM >wrote in message
Quote
I am just trying to make a design time property form for setting
properties pretaining to some graphing settings.
Earlier, you were creating a Component Editor, not a Property Editor.
Component Editors have nothing to do with the Object Inspector. Are you now
creating a Property Editor?
Quote
If I just list all of them in the Object Inspector there would be hundreds
of Properties in there and it makes the VCL component yucky to use.
If you have all 100+ plus properties in a single class, then yes. Which is
why you should consider use multiple nested classes. Then properties can be
expanded/collapsed in the Object Inspector.
Quote
I believe doing it this way will make the component alot more friendly for
editing. I have it working but I was just trying to get the class name to
display like TFont and TConstraints does, it's not important just wanted
to make it like the others.
What you describe is in the Object Inspector, which has nothing to do with
Component Editors, only Propety Editors. So what EXACTLY are you
implementing? You keep changing your descriptions, so it is very difficult
to know what you are actually doing.
Quote
As for the Property, I am creating an instance of TComponentProperty,
and if you click the ellipsis (...) it opens a form that has all the
settings
pretaining to that group. The class name being display isn't a big deal,
I can live without that.
The Object Inspector already displays the class name of a property, so why
are you trying to set it manually?
Gambit
 

Re:Component Editor problems

Remy Lebeau (TeamB) wrote:
Quote
Earlier, you were creating a Component Editor, not a Property Editor.
Component Editors have nothing to do with the Object Inspector. Are you now
creating a Property Editor?

I was making a Component Editor earlier but found out that it was the
wrong thing to do. Like I said I'm new to this kind of stuff and doing
stuff wrong the first time happens.
Quote

The Object Inspector already displays the class name of a property, so why
are you trying to set it manually?

Umm I'm new to this stuff and thought it had to be set manually...
Shannon
 

Re:Component Editor problems

I have placed my code in attachments newsgroup under title
"PropertyEditor Attempt".
I cleaned it out down to pretty much the bare bones so figuring out my
problem can be done easier without a bunch of code.
I believe I am having a design time / run time problem because when I
place the component onto a form in an application and try to compile I
get a bunch of linker unresolved external errors. The design time stuff
seems to work but now I can't compile.
How would you layout the design of these files? I've tried finding a
good example of what I am trying to do on the web but I get fragments
and nothing shows a complete set of code from beginning to end.
Could somebody (Remy) please take a quick look at the code I posted and
tell me what I am doing wrong that would cause this to happen. How
would you fix it. What am I not doing? I'm dumb? Whatever response
will help I think...
Thanks
Shannon
 

Re:Component Editor problems

SP wrote:
Quote
I have placed my code in attachments newsgroup under title
"PropertyEditor Attempt".

I cleaned it out down to pretty much the bare bones so figuring out my
problem can be done easier without a bunch of code.

I believe I am having a design time / run time problem because when I
place the component onto a form in an application and try to compile I
get a bunch of linker unresolved external errors. The design time stuff
seems to work but now I can't compile.

How would you layout the design of these files? I've tried finding a
good example of what I am trying to do on the web but I get fragments
and nothing shows a complete set of code from beginning to end.

Could somebody (Remy) please take a quick look at the code I posted and
tell me what I am doing wrong that would cause this to happen. How
would you fix it. What am I not doing? I'm dumb? Whatever response
will help I think...

Thanks

Shannon
Oh and if I ever use the componet borland crashes when doing a
File->Exit. So I have to be doing something majorly wrong.
Shannon
 

Re:Component Editor problems

"SP" < XXXX@XXXXX.COM >wrote in message
Quote
I believe I am having a design time / run time problem because
when I place the component onto a form in an application and try
to compile I get a bunch of linker unresolved external errors. The
design time stuff seems to work but now I can't compile.
Design-time code is not allowed to be compiled into executables. Nor should
it be anyway, since it only benefits the IDE to begin with, not the compiled
executable. You need to move your design-time code into a separate package
than your component. Mark the component package as "Runtime only" in the
Project Option. Mark the editor package as "Designtime only" in the Project
Options, and add the component package to the Requires list. Then install
both packages into the IDE, with the component Runtime package being first
so the Designtime editor package can find it.
Gambit
 

Re:Component Editor problems

Remy Lebeau (TeamB) wrote:
Quote
"SP" < XXXX@XXXXX.COM >wrote in message
news:424c747f$ XXXX@XXXXX.COM ...


>I believe I am having a design time / run time problem because
>when I place the component onto a form in an application and try
>to compile I get a bunch of linker unresolved external errors. The
>design time stuff seems to work but now I can't compile.


Design-time code is not allowed to be compiled into executables. Nor should
it be anyway, since it only benefits the IDE to begin with, not the compiled
executable. You need to move your design-time code into a separate package
than your component. Mark the component package as "Runtime only" in the
Project Option. Mark the editor package as "Designtime only" in the Project
Options, and add the component package to the Requires list. Then install
both packages into the IDE, with the component Runtime package being first
so the Designtime editor package can find it.


Gambit


Ok did that, how and were do I add the RegisterPropertyEditor command.
If I do it in the Editor package it doesn't seem to do anything.
here is what I add to the editor package.
namespace Graphcomponenteditor
{
void __fastcall PACKAGE Register()
{
RegisterPropertyEditor(__typeinfo(TGraph), NULL, "Graph",
__classid(TGraphProperty));
}
}
my code is pretty much the same as in the last attachment except I
pulled the files pretaining to the Editor out and placed them in thier
own package and added the above namespace. I placed the new bpi into
the required filed. compiled everything and that all works but I get no
IDE interface for the Editor. I'm appearantly not understanding where
to place this Register function call....
Shannon