Hi All ,

I needed to change Default Text attributes (font and color) . So I wrote following code , UnicodeTextOut function. I called this function once in each 55ms to update the display screen. but I observed that my Screen used to become grey
like a crash after sometime . If I use Minimize an Maximize window , the screen was restoring back for some time.

When I thought over the code , I got my mistake that CreateFont initialization should be done once in the program and probably outside the function.

void UnicodeTextOut(int x, int y, CString s, UINT justify,int GreyScaleFlag)
{


HFONT hFontUnicode;
HFONT hfOld ;

hFontUnicode = CreateFont(16, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0, _T("Aerial"));
hfOld = (HFONT) SelectObject(hdc, hFontUnicode);

SetBkColor(hdc,(RGB(128,128,128)));
SetTextColor(hdc,(RGB(255,255,255)));
SetTextAlign(hdc, justify);
TextOut(hdc, x, y, s, s.GetLength());

SelectObject(hdc, hfOld);

}


Then I shifted the line hFontUnicode = CreateFont(16, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0, _T("Aerial")); in my screen class constructor and made hFontUnicode global .

This solved my problem as expected.

PL explain me why a system crash after certain no of CreateFont calls ? I am curious to know.
pl pl ..