Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How can I resolve "Ambiguity between TFont and Graphics::TFont" error?

focussedfocussed Member Posts: 3
I am trying to use the CustomDrawCell event for the TdxTreeListColumn column object.

When the method is added in .h file,

void __fastcall dxTreeListServiceCustomDrawCell(TObject *Sender,
TCanvas *ACanvas, TRect &ARect, TdxTreeListNode *ANode,
TdxTreeListColumn *AColumn, bool ASelected, bool AFocused,
bool ANewItemRow, AnsiString &AText, TColor &AColor,
TFont *AFont, TAlignment &AAlignment, bool &ADone);

When I try to compile this I get the following errors,

Error1 - Ambiguity between TRect and Windows:TRect
Error1 - Ambiguity between TFont and Graphics:TFont
Error1 - Ambiguity between TColor and Graphics:TColor

I am using C++ Builder 5.0 Professional

Comments

  • LundinLundin Member Posts: 3,711
    You get that error when two types in two different namespaces are named the same thing. Solve it by telling the compiler which one you mean, by writing the namespace explicitly in front of the type. Like Graphics::TFont.
  • focussedfocussed Member Posts: 3
    I tried doing that, but doing that is not resolving the problem.
    When I try to save the file after making the change, the IDE throws an error saying the method for the event does not exist and do you want to remove the reference.

    Since this method declaration is generated by the IDE itself, i do not think we can modify the signature...
  • focussedfocussed Member Posts: 3
    I have resolved the error related to ambiguity between TFont and Graphics::TFont and ambiguity between TColor and Graphics::TColor by using



    namespace Graphics {

    using Graphics::TFont;

    using Graphics::TColor;





    }

    but how can I resolve the remaining error?
    the ambiguity between TRect and Windows::TRect?



  • luckyboyluckyboy Member Posts: 105
    well, if your class definition is outside any [b]namespace[/b], then you can not prefix it with the [b]namespace[/b] in this manner
    Graphics::TFont

    so, i suggest to tell the compiler that it is not part of any [b]namespace[/b] declaration by typing this explicitly
    ::TFont, ::TRect, ::TColor.

    ths should work fine, if these three classes definitions appear outside any [b]namespace[/b] ,since :: without any [b]namespace[/b] prefix (ie the unary version of this operator) means GLOBAL
    try to use it to distinguish between your local and global variables that carry the same name, or even static-member-functions and global functions that carry the same name.
    see ya
    Mohammad Nasim
Sign In or Register to comment.