[python-win32] Re: OnCtlColor not working?

Roger Upole rwupole at msn.com
Mon Mar 2 05:02:24 CET 2009


Greg Ewing wrote:
> Has anyone successfully used the PyCWnd.OnCtlColor
> virtual function to change the appearance of a
> control?
> 
> The program below tries to use it to set the colour
> of the text in a PyCButton. My OnCtlColor method gets
> called, but it doesn't have any effect on the appearance
> of the button.
> 
> Also, if I attempt to return a PyCBrush from the
> OnCtlColor method as the docs suggest, I get
> "TypeError: An integer is required" errors.
> 
> Am I doing something wrong?

OnCtlColor is expected to return a GDI handle rather than a full
MFC object.  Try something like:

return win32gui.CreateSolidBrush(win32api.RGB(255,0,0)).Detach()

       Roger



More information about the python-win32 mailing list