1  OnCtlColorHBRUSH CXxxxxxxDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

if (pWnd->GetDlgCtrlID() == IDC_EDIT1)
{
pDC->SetTextColor(RGB(255,8,0));//
COLORREF COLOR=RGB(183,234,0);
pDC->SetBkColor(COLOR);
flag = TRUE;
return CreateSolidBrush(COLOR);
} // TODO: Return a different brush if the default is not desired
return hbr;
}void CXxxxxxxDlg::OnTimer(UINT nIDEvent) 
{
// TODO: Add your message handler code here and/or call default
ReadNotes();
iCount++; CDialog::OnTimer(nIDEvent);
} CString strMsg;
srand((unsigned)time( NULL ));
int g = rand();
strMsg.Format("%s,%d,%d", "中国网谁赛法纪科学,发发非阿嘎阿",iCount,g);
m_notes = strMsg;
UpdateData(FALSE);SetTimer(100,10,NULL);

解决方案 »

  1.   

    CXxxxxxxDlg::ReadNotes()
    {
    CString strMsg;
    srand((unsigned)time( NULL ));
    int g = rand();
    strMsg.Format("%s,%d,%d", "中国网谁赛法纪科学,发发非阿嘎阿",iCount,g);
    m_notes = strMsg;
    UpdateData(FALSE);}
      

  2.   

    每次都创建一个新画笔从来都没有释放,所以系统GDI资源枯竭,导致菜单完蛋OnCtrlColor中
    return CreateSolidBrush需要修改应该始终保持一个Brush,而不是每刷新一次数据就创建一个Brush
      

  3.   

    GDI资源才5000个?这么快就被我用光了.:)
      

  4.   

    怎么修改?CreateSolidBrush返回的是一个BOOL?
      

  5.   

    你的资源再多也不能装下5000个Brush应该增加一个退出时增加一个释放函数
      

  6.   

    ok 了谢谢大虾 jingyad() !看来window 最多也才5000个gdi 准确的说好像是 4908多个。