您的位置:首页 > 其它

VC程序启动画面

2008-12-31 01:50 176 查看
HBITMAP hBmp; //要显示的位图
hBmp = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAPgtlogo));
HDC hScreenDC = CreateDC("DISPLAY", NULL, NULL, NULL); //屏幕DC
HDC hMemDC = CreateCompatibleDC(hScreenDC); //内存DC
int iScreenWidth = ::GetDeviceCaps(hScreenDC, HORZRES); //屏幕的宽
int iScreenHeight = ::GetDeviceCaps(hScreenDC, VERTRES); //屏幕的高
BITMAP bmpInfo;
GetObject(hBmp, sizeof(BITMAP), &bmpInfo);
int iBmpWidth = bmpInfo.bmWidth; //位图宽
int iBmpHeight = bmpInfo.bmHeight; //位图高
int x = (iScreenWidth - iBmpWidth) / 2; //显示的x位置
int y = (iScreenHeight - iBmpHeight) / 2; //显示的y位置
SelectObject(hMemDC, hBmp);
::BitBlt(hScreenDC, x, y, iScreenWidth, iScreenHeight, hMemDC, 0, 0, SRCCOPY);
Sleep(2000); //查看效果
//释放资源
DeleteDC(hMemDC);
DeleteDC(hScreenDC);
DeleteObject(hBmp);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: