开发者

MFC Crash on repeated SetWindowText() when a background color for the dialog is specified

开发者 https://www.devze.com 2022-12-22 02:42 出处:网络
The following code works fine: for(int i=0; i<500; i++) { for(int j=0; j<100; j++) { m_title.SetWindowText(_T(\"lol\"));

The following code works fine:

for(int i=0; i<500; i++) {

for(int j=0; j<100; j++) {

m_title.SetWindowText(_T("lol"));

}

}

But when I set a background color for the dialog:

HBRUSH CTaggingDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) {

return CreateSolidBrush(RGB(0,0,0));//BLACK

}

The 开发者_如何学JAVAloop above causes the program to hit a breakpoint in wingdi.cpp at:

CPaintDC::CPaintDC(CWnd* pWnd)

How do I set a background color for the dialog without having it crash?


Never mind. By changing the way I set the background color to the method in this article:

http://www.codeguru.com/cpp/w-d/dislog/background/article.php/c1895

The problem has been resolved.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号