[wxMSW] What is the best way to get notified when the background or forground colors of a control changes? Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
tomay3000
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Mon Apr 24, 2017 4:23 am

[wxMSW] What is the best way to get notified when the background or forground colors of a control changes?

Post by tomay3000 »

Hello,
I need to know where to intercept the background and forground color changes of a control.
Is there an event I don't know about?
What is the best way to do it?

TIA.
User avatar
doublemax@work
Super wx Problem Solver
Super wx Problem Solver
Posts: 474
Joined: Wed Jul 29, 2020 6:06 pm
Location: NRW, Germany

Re: [wxMSW] What is the best way to get notified when the background or forground colors of a control changes?

Post by doublemax@work »

No event is triggered in these cases. But the only time this could happen, is when you change the color yourself, isn't it? So why would you need to get notified?
tomay3000
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Mon Apr 24, 2017 4:23 am

Re: [wxMSW] What is the best way to get notified when the background or forground colors of a control changes?

Post by tomay3000 »

I use a sub-classed wxControl, and I need to update the drawing inside that sub-classed control according to the background and foreground colors.
So if later I use mySubClassedControl.SetBackgroundColour() or mySubClassedControl.SetForgroundColour(), then how do I know inside the sub-classed control if the color was changed!
Last edited by tomay3000 on Mon Aug 03, 2020 5:55 pm, edited 1 time in total.
User avatar
doublemax@work
Super wx Problem Solver
Super wx Problem Solver
Posts: 474
Joined: Wed Jul 29, 2020 6:06 pm
Location: NRW, Germany

Re: [wxMSW] What is the best way to get notified when the background or forground colors of a control changes?

Post by doublemax@work »

Override these two methods and either perform the necessary changes immediately, or set a flag and perform them when the next paint event is received.
tomay3000
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Mon Apr 24, 2017 4:23 am

Re: [wxMSW] What is the best way to get notified when the background or forground colors of a control changes?

Post by tomay3000 »

I completely missed that these methods are virtual and probably was made like that for this reason.
Thank you.
Post Reply