Michael_J
Topic Author
Posts: 20
Joined: 02 Apr 2014, 14:22

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

19 Aug 2014, 23:56

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...
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

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

20 Aug 2014, 13:45

This should work:
Ptr<Brush> fill = *new SolidColorBrush(Color::Red);
rectangle->SetFill(fill.GetPtr());
If not, tell me more about your scenario please.
 
Michael_J
Topic Author
Posts: 20
Joined: 02 Apr 2014, 14:22

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

20 Aug 2014, 17:55

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... :)
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

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

20 Aug 2014, 18:01

Yes, the Ptr handles the memory automatically for you.
 
Michael_J
Topic Author
Posts: 20
Joined: 02 Apr 2014, 14:22

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

20 Aug 2014, 18:04

Cheers. Thanks again for the help...

Who is online

Users browsing this forum: No registered users and 55 guests