Hi,
I have a custom control derived from wxControl. I am overriding the EVT_PAINT and doing all the drawing there, How should I handle the Disabled state of the control.
Do I need to check if control is disabled inside the OnPaint function and then change all the colors accordingly.
Is there no way of easily handling this?
Thanks,
Vikram
Custom control OnPaint when control is disabled Topic is solved
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
Re: Custom control OnPaint when control is disabled
wxWindow::Enable() is a virtual method, and calling Disable() just calls Enable(false). So I believe that if you override this method while still calling the parent method, you have the ability to tie into that, and trigger a repaint with your control disabled if you need to.
Re: Custom control OnPaint when control is disabled
Thanks tierra. Seems to be a good suggestion. I will try this.
Just a doubt: If I call Enable() function on a window, does it call Enable() recursively to all of its children?
I am guessing the answer should be yes but it would be great if you can confirm it.
Just a doubt: If I call Enable() function on a window, does it call Enable() recursively to all of its children?
I am guessing the answer should be yes but it would be great if you can confirm it.
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
Re: Custom control OnPaint when control is disabled
wxMSW and wxOSX/Carbon are the only two platforms I'm not entirely sure this is true. They have some automatic, native implementation for disabling their child windows where wxWindow::Enable() might not be called directly. wxWidgets recursively disables child windows itself on all other platforms.vikram731 wrote:Just a doubt: If I call Enable() function on a window, does it call Enable() recursively to all of its children?
I am guessing the answer should be yes but it would be great if you can confirm it.
In any case, this should be rather simple to test out in just about any sample that derives a new control of any kind.