Tech Support > Microsoft Windows > Development Resources > Custom Draw - Change background color for TrackBar control
Custom Draw - Change background color for TrackBar control
Posted by Stanley on April 28th, 2004


Hi,

I'm using WTL 7.1 and I would like to set my WTL TrackBar control to a
white background during runtime.

I've setup a handler declaration for the custom draw message like
such:
BEGIN_MSG_MAP(cTouchUpPanel)
....
NOTIFY_HANDLER(IDC_BRIGHTNESS, NM_CUSTOMDRAW,
OnBrightnessCustomDraw)
....
END_MSG_MAP()

and the handler looks like this:
LRESULT cTouchUpPanel::OnBrightnessCustomDraw(int, LPNMHDR pnmh,
BOOL&)
{
NMCUSTOMDRAW* pCustom = (NMCUSTOMDRAW*) pnmh;
SetBkColor(pCustom->hdc, RGB(255, 255, 255));

return TRUE;
}

I've placed a breakpoint at the OnBrightnessCustomDraw() method and it
did get called. But the color of my TrackBar is still the default
gray color, instead of the intended white.

Anyone has a clue?
Thanks!

Posted by Christian ASTOR on April 28th, 2004


Stanley a écrit:


The background color can be changed on WM_CTLCOLORSTATIC of the parent.
(SetBkColor(), return GetStockObject(WHITE_BRUSH))


Posted by Stanley on April 29th, 2004


Thanks for the tip - it works great!


Christian ASTOR <castorix@club-internet.fr> wrote in message news:<uRUIePRLEHA.1484@tk2msftngp13.phx.gbl>...


Similar Posts