如何使对话框中的位图移动并且不要闪???
我用的是单文档的框架,以下是我显示位图的对话框中的一部分程序。图片虽然可移动,但在移动过程中不断闪烁,请个位高手多多指教。
void CPreView::OnPaint()
{
// device context for painting
CPaintDC dc(this);
// TODO: Add your message handler code here
hwnd = GetDlgItem(IDC_PIC);
hDesDC = hwnd->GetDC()->m_hDC;
hSrcDC = CreateCompatibleDC(hDesDC);
hBitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),m_Path,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hBitmap, sizeof BITMAP, &bm);
SelectObject(hSrcDC, hBitmap);
hwnd->GetClientRect(&rect);
SetTimer(0,10,NULL);
}
void CPreView::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(m_X!=0&&m_X<1000)
{
::BitBlt(hDesDC,rect.left, 0, rect.right,rect.bottom, hSrcDC, -m_X+bm.bmWidth+1, 0,R2_BLACK);
}
if(m_X<1000)
{
::BitBlt(hDesDC,rect.left, rect.top, rect.right, rect.bottom, hSrcDC, -m_X+bm.bmWidth, 0, SRCCOPY);
m_X+=1;
}
CDialog::OnTimer(nIDEvent);
}