Color change ignored

I have some sort of legend in my report. It's just a bunch of TfrxLineView objects. During design time those were assigned some default values. However, those colors are now configurable elsewhere which means that I have to adjust those legend colors dynamically.

The code essentially looks like this (just like the code for e.g. text filling):


 auto o=dynamic_cast<TfrxView*>(fr.FindComponent("legend_line"));

 if(o) {

  o->Color=some_tcolor;

 }


However, the preview doesn't show the new colors but the old predefined ones, the above code has zero effect.

Do I have to issue some sort of Update on object o or the report or is this a bug? Is there some workaround?


Thanks in advance!

Comments

  • Note, changing the attributes of "Fill" doesn't work neither:


    auto f=dynamic_cast<TfrxBrushFill>(view->Fill);

    if(f) {

       f->ForeColor=new_color;

       f->BackColor=new_color;

    }


    The code is being execute (so Fill is set and is a TfrxBrushFill), but also has zero effect.

  • Found it... Phew, man:

    At least for objects of type TfrxLineView changing the Color or Fill->ForeColor has no effect if done programatically.

    But there is yet another Color attribute for those objects, hidden inside the Frame attribte. And this actually works. Because I have no idea if other TfrxView descendants behave different, I now do all variants.

    Here's the complete snippet if somebody taps into this problem too:


    void SetObjectColor(TfrxReport &r, const char *name, TColor col)

    {

    auto o=dynamiccast<TfrxView>(r.FindComponent(name));

    if(o) {

    o->Color=c; // try the obvious which failed for me

    auto f=dynamiccast<TfrxBrushFill>(o->Fill);

    if(f) {

    f->ForeColor=c; // the next one which failed too

    }

    auto fr=o->Frame;

    if(fr) {

    fr->Color=c; // yay, this one works with my TfrxLineView

    }

    }

    }


    Cheers

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.