本文使用两种方法来实现。
方法:重载 OnPaint() 函数:
void C***View::OnPaint()
{
try{
CPaintDC dc(this); // device context for painting
CRect rt;
GetClientRect(&rt);
int nWidth = rt.Width();
int nHeight = rt.Height();
CDC MemDC;
CBitmap MemBitmap;
MemDC.CreateCompatibleDC(NULL);
MemBitmap.CreateCompatibleBitmap(&dc,nWidth,nHeight);
CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);
MemDC.FillSolidRect(0,0,nWidth,nHeight,RGB(0,0,0));
/*CPen pen(PS_SOLID,2,RGB(0,0,128));
CPen *pOldPen = MemDC.SelectObject(&pen);
MemDC.SelectObject(pOldPen);*/
CFont font;
VERIFY(font.CreateFont(
48,
0,
0,
0,
700,
FALSE,
FALSE,
0,
GB2312_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS,
"幼圆"));
CFont* def_font = MemDC.SelectObject(&font);
MemDC.SetTextColor(RGB(255,0,0));
MemDC.TextOut(nWidth/2-250,nHeight/2,"服务器接口程序,请勿关闭!");
MemDC.SelectObject(def_font);
// Done with the font. Delete the font object.
font.DeleteObject();
dc.BitBlt(0,0,nWidth,nHeight,&MemDC,0,0,SRCCOPY);
MemBitmap.DeleteObject();
MemDC.DeleteDC();
}catch (...){
}
}
来源:CSDN
作者:米小鸢
链接:https://blog.csdn.net/u012372584/article/details/77868748