怎样实现动画背景旗帜(2)
VERIFY(m_bmpBackGround.GetObject(sizeof(bm), (LPVOID) &bm));
dcMem.CreateCompatibleDC(NULL);
CBitmap *pbmpOld = (CBitmap*)dcMem.SelectObject(&m_bmpBackGround);
ASSERT(pbmpOld);
// Display red background
pDC->StretchBlt(0, 0, rect.right, rect.bottom, &dcMem, 0, 0, bm.bmWidth,
bm.bmHeight, SRCCOPY);
VERIFY(m_bmpBackGround2.GetObject(sizeof(bm2), (LPVOID) &bm2));
dcMem2.CreateCompatibleDC(NULL);
dcMem2.SelectObject(&m_bmpBackGround2);
// Display picture background
pDC->StretchBlt(200, 100, 400, 200, &dcMem2, 0, 0, bm2.bmWidth, bm2.bmHeight,
SRCCOPY);
// Display Instructions
pDC->SetBkColor(RGB(255, 0, 0));
pDC->SetTextColor(RGB(192, 192, 192));
pDC->TextOut(480, 500, "Mouse Right Click to Stop/Start Special Effects");
pDC->TextOut(480, 515, "Mouse Left-Click to Show Child Window");
// CleanUp
dcMem.SelectObject(pbmpOld);
return TRUE;
}
////////////////////////////////////////////////////////////////////
//
void CMdiMainClient::OnSize(UINT nType, int cx, int cy)
{
Default();
// if the app is just starting up, save the window
// dimensions and get out
if ((m_sizeClient.cx == 0) && (m_sizeClient.cy == 0))
{
m_sizeClient.cx = cx;
m_sizeClient.cy = cy;
return ;
}
// if the size hasn't changed, break and pass to default
if ((m_sizeClient.cx == cx) && (m_sizeClient.cy == cy))
{
return ;
}
// window size has changed so save new dimensions and force
// entire background to redraw, including icon backgrounds
m_sizeClient.cx = cx;
m_sizeClient.cy = cy;
RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW |
RDW_ALLCHILDREN);
- 上一篇:在对话框中动态显示位图
- 下一篇:Visual C++中建立滚动视窗