|
我在更新文本的时候,文本有时在闪,为什么?文本显示的内容是时间,在不停的更新。
GetLocalTime(&time0);
CString str;
str.Format(_T("年月日:%04d:%02d:%02d时间:%02d:%02d:%02d,星期:%01d"),
time0.wYear, time0.wMonth, time0.wDay,
time0.wHour, time0.wMinute, time0.wSecond,
time0.wDayOfWeek);
BITMAP bmpInfo;
BackScreenBitmap.GetBitmap(&bmpInfo);
CDC dcMemory;
dcMemory.CreateCompatibleDC(&dc);
// Select the bitmap into the in-memory DC
CBitmap* pOldBitmap = dcMemory.SelectObject(&BackScreenBitmap);
// Find a centerpoint for the bitmap in the client area
CRect rect;
GetClientRect(&rect); //该函数获取窗口客户区的坐标。
dc.BitBlt(0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory, 0, 0, SRCCOPY);
DrawText(hDC, str, wcslen(str), &TextRect, DT_VCENTER ) ;
dcMemory.SelectObject(pOldBitmap);
delete pOldBitmap ;
dcMemory.DeleteDC () ;
|
|