一个奇怪的有关问题,请各位帮忙看看,多谢了
一个奇怪的问题,请各位帮忙看看,谢谢了
我利用Timer定时修改static text的颜色,代码如下,开始还对,运行一段时间后static text的颜色全部变成灰色了,在也没变换,问题出在那里???
case WM_TIMER:
for (i=0;i <10;i++)
{
InvalidateRect(GetDlgItem(hDlg,ColorID[i]),lpRect[i],FALSE);
}
return true;
break;
case WM_CTLCOLORSTATIC:
for (i=0;i <10;i++)
{
hBrush[i]=0;
if( lParam == (LPARAM)::GetDlgItem( hDlg,ColorID[i]) )
{
RBG_r = (Palette[i] & 0x7C00) > > 10; //hig 5bit
RBG_g = (Palette[i] & 0x03E0) > > 5; //mid 5bit
RBG_b = (Palette[i] & 0x001F); //low 5bit
HDC hdc = (HDC )wParam ;
::SetTextColor( hdc,RGB(RBG_r < <3,RBG_g < <3,RBG_b < <3));
::SetBkMode( hdc, RGB(RBG_r < <3,RBG_g < <3,RBG_b < <3) );
if (hBrush[i]==0)
hBrush[i]=CreateSolidBrush( RGB(RBG_r < <3,RBG_g < <3,RBG_b < <3) );
return ( INT_PTR )hBrush[i];
}
}
break;
------解决方案--------------------
你先不要用太多STATIC控件试一下。
------解决方案--------------------
GDI资源泄漏,每次创建前先销毁原来的画刷。
我利用Timer定时修改static text的颜色,代码如下,开始还对,运行一段时间后static text的颜色全部变成灰色了,在也没变换,问题出在那里???
case WM_TIMER:
for (i=0;i <10;i++)
{
InvalidateRect(GetDlgItem(hDlg,ColorID[i]),lpRect[i],FALSE);
}
return true;
break;
case WM_CTLCOLORSTATIC:
for (i=0;i <10;i++)
{
hBrush[i]=0;
if( lParam == (LPARAM)::GetDlgItem( hDlg,ColorID[i]) )
{
RBG_r = (Palette[i] & 0x7C00) > > 10; //hig 5bit
RBG_g = (Palette[i] & 0x03E0) > > 5; //mid 5bit
RBG_b = (Palette[i] & 0x001F); //low 5bit
HDC hdc = (HDC )wParam ;
::SetTextColor( hdc,RGB(RBG_r < <3,RBG_g < <3,RBG_b < <3));
::SetBkMode( hdc, RGB(RBG_r < <3,RBG_g < <3,RBG_b < <3) );
if (hBrush[i]==0)
hBrush[i]=CreateSolidBrush( RGB(RBG_r < <3,RBG_g < <3,RBG_b < <3) );
return ( INT_PTR )hBrush[i];
}
}
break;
------解决方案--------------------
你先不要用太多STATIC控件试一下。
------解决方案--------------------
GDI资源泄漏,每次创建前先销毁原来的画刷。