Page 1 of 1

Change fill color of a rectangle at runtime (c++)

Posted: 19 Aug 2014, 23:56
by Michael_J
Hi all :)

Subject says it all--I'm simply trying to change the fill color of a rectangle at run time via c++. Seems like a simple thing but I'm having no luck. Obviously I'm overlooking the obvious :)

Thanks for any help...

Re: Change fill color of a rectangle at runtime (c++)

Posted: 20 Aug 2014, 13:45
by jsantos
This should work:
Ptr<Brush> fill = *new SolidColorBrush(Color::Red);
rectangle->SetFill(fill.GetPtr());
If not, tell me more about your scenario please.

Re: Change fill color of a rectangle at runtime (c++)

Posted: 20 Aug 2014, 17:55
by Michael_J
Based on your example, I used this so I could precisely set the color:
Noesis::Ptr<Noesis::Gui::Brush> Fill = *new Noesis::Gui::SolidColorBrush(Noesis::Drawing::Color(0, 255, 0));
rectangle->SetFill(Fill .GetPtr());
But yes, works great. Your Noesis::Ptr handles the cleanup, yes? I don't have to delete that "*new"?

Thanks again... :)

Re: Change fill color of a rectangle at runtime (c++)

Posted: 20 Aug 2014, 18:01
by jsantos
Yes, the Ptr handles the memory automatically for you.

Re: Change fill color of a rectangle at runtime (c++)

Posted: 20 Aug 2014, 18:04
by Michael_J
Cheers. Thanks again for the help...