{ CBitmap bmp, poldbmp;/*定义变量*/ BITMAP bmpStruct; CDC memdc; CRect bmpRect, clientRect; CBrush backBrush(RGB(0,0,0));/*设置背景颜色*/ CBrush* pOldBrush = pDC->SelectObject(&backBrush); /*获得分配内存大小*/ GetClientRect(&clientRect); /* 载入新图到分配内存中*/ pDC->FillRect(&clientRect, &backBrush); bmp.LoadBitmap(IDB_WINCE_BITMAP); bmp.GetBitmap(&bmpStruct); /*设置位图尺寸*/ bmpRect.left = clientRect.left + (clientRect.Width() - bmpStruct.bmWidth)/2; bmpRect.top = clientRect.top + (clientRect.Height() - bmpStruct.bmHeight)/2; bmpRect.right = clientRect.right - (clientRect.Width()- bmpStruct.bmWidth)/2; bmpRect.bottom=clientRect.bottom-(clientRect.Height()-bmpStruct.bmHeight)/2; /*分配一个新的内存地址*/ memdc.CreateCompatibleDC(pDC); /*调入位图到新分配内存*/ poldbmp = memdc.SelectObject( &bmp ); /*输入位图到屏幕*/ pDC->BitBlt(bmpRect.left,bmpRect.top, bmpRect.right,bmpRect.bottom,&memdc, 0,0, SRCCOPY); memdc.SelectObject(poldbmp); pDC->SelectObject(pOldBrush); return TRUE; } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |