Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think.com!linus!philabs!ttidca!woodside@ttidcb.tti.com From: woodside@ttidcb.tti.com (George Woodside) Newsgroups: comp.windows.ms.programmer Subject: Button Colors Message-ID: <21843@ttidca.TTI.COM> Date: 13 Dec 90 15:46:59 GMT Sender: woodside@ttidca.TTI.COM Organization: Citicorp/TTI, Santa Monica Lines: 34 I've been unable to change the color of a button, created inside a window. I've followed the example in Petzold's book, and tried various other attempts, but the child button remains gray. The 'ybrush' handle is valid, and has been used successfully. "SPY" shows the messages are being received as expected, and debug logs show all values are as expected. But, the child buttons remain gray, instead of being painted yellow. Any help anyone can offer will be appreciated. The unsuccessful code segment: extern HBRUSH ybrush; /* yellow brush for folder */ long FAR PASCAL WndProc(HWND hwnd, unsigned message, WORD wParam, LONG lParam) { POINT point; /* origin point for child brush */ .... switch (message) /* check message type */ { .... case WM_CTLCOLOR: /* child button repainting */ if (HIWORD(lParam) == CTLCOLOR_BTN) /* if a button repaint */ { SetBkColor((HDC) wParam, RGB(255, 255, 0)); /* set yellow background */ SetTextColor((HDC) wParam, R(0, 0, 0)); /* text black */ UnrealizeObject(ybrush); /* reset brush origin */ point.x = 0; /* horizontal synch with child */ point.y = 0; /* vertical synch with child */ ClientToScreen((HDC) wParam, &point); /* synch to client window */ SetBrushOrg((HDC) wParam, point.x, point.y); /* synch the brush */ return ((DWORD) ybrush); /* paint button in yellow */ } /* end child button repaint */ break; .... } /* end message switch */ } /* end WndProc */