Well, it *almost* works now... it's okay for all the
button styles except BS_PUSHBUTTON.

My OnCtlColor is still getting called, but the
pushbutton seems to ignore the results. All the other
button styles are okay.

Am I still doing something wrong, or is this a known
limitation of pushbuttons?

#-----------------------------------------------------

import win32con, win32ui, win32gui, win32api
from pywin.mfc.object import Object

b = win32ui.CreateBrush()
b.CreateSolidBrush(0x00ff00)
hb = b.GetSafeHandle()

class MyFrame(Object):

        def OnCtlColor(self, dc, btn, typ):
                print "MyFrame.OnCtlColor:", self ###
                dc.SetTextColor(0x0000ff)
                dc.SetBkColor(0x00ff00)
                return hb
        
def add_button(title, style, y):
        button = win32ui.CreateButton()
        button.CreateWindow(title, style, (20, y, 100, y + 20),
                frame, 0)
        button.ShowWindow(win32con.SW_SHOW)

frame = MyFrame(win32ui.CreateFrame())
frame.CreateWindow(None, "Test", win32con.WS_CAPTION,
        (100, 100, 300, 300))

add_button("Push", win32con.BS_PUSHBUTTON, 20)
add_button("Check", win32con.BS_CHECKBOX, 50)
add_button("Radio", win32con.BS_RADIOBUTTON, 80)
add_button("Group", win32con.BS_GROUPBOX, 110)
add_button("3State", win32con.BS_3STATE, 140)

frame.ShowWindow()
app = win32ui.GetApp()
app.Run()

#-----------------------------------------------------

--
Greg

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to