1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
//---------------------------------------------------------------------------------
virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
if(message==WM_CTLCOLOR)
{
_AFX_CTLCOLOR* pCtl = (_AFX_CTLCOLOR*)lParam;
CDC dcTemp; dcTemp.m_hDC = pCtl->hDC;
CWnd wndTemp; wndTemp.m_hWnd = pCtl->hWnd;
UINT nCtlType = pCtl->nCtlType;
if(nCtlType==CTLCOLOR_STATIC)
{
char szClassName[30];
if(GetClassName(pCtl->hWnd,szClassName,sizeof(szClassName)))
if(strcmp(szClassName,"Static")) nCtlType=0;
}
if(nCtlType==CTLCOLOR_DLG || nCtlType==CTLCOLOR_STATIC)
{
HBRUSH hbr = OnCtlColor(&dcTemp, &wndTemp, nCtlType);
// fast detach of temporary objects
dcTemp.m_hDC = NULL;
wndTemp.m_hWnd = NULL;
*pResult = (LRESULT)hbr;
return TRUE;
}
// fast detach of temporary objects
dcTemp.m_hDC = NULL;
wndTemp.m_hWnd = NULL;
}
return GENERIC_DLGCOLOR::OnWndMsg(message, wParam, lParam, pResult);
} |