kathy
2006-03-22 23:26:27 UTC
My dialog has a Static control. I have a bitmap and want to draw it in
the Static control when dialog pop up. I implement DrawBitmap() and
called it in OnInitDialog().
MyDialog::OnInitDialog()
{
...
DrawBitmap();
}
MyDialog::DrawBitmap()
{
HWND hWnd = 0;
HDC hDC = 0;
INT nCx = 0,nCy = 0,nY = 0;
RECT stCR ={0};
CClientDC dc(this); // device context for painting
hWnd = ::GetDlgItem(this->m_hWnd,IDC_STATIC_IMAGE);
::GetClientRect(hWnd,&stCR);
nCx = stCR.right - stCR.left;
nCy = stCR.bottom - stCR.top;
hDC = ::GetDC(hWnd);
StretchDIBits(hDC,stCR.left,stCR.top,nCx,nCy,0,0,m_nCameraCX,m_nCameraCY,m_pstBytes,m_pstBMI,DIB_RGB_COLORS,SRCCOPY);
}
But I can not see the bitmap. Even I put it in the OnPaint(). I still
can not see it.
If I add timer and add it in OnPaint() and called it in OnTimer(). I
can see it. why?
the Static control when dialog pop up. I implement DrawBitmap() and
called it in OnInitDialog().
MyDialog::OnInitDialog()
{
...
DrawBitmap();
}
MyDialog::DrawBitmap()
{
HWND hWnd = 0;
HDC hDC = 0;
INT nCx = 0,nCy = 0,nY = 0;
RECT stCR ={0};
CClientDC dc(this); // device context for painting
hWnd = ::GetDlgItem(this->m_hWnd,IDC_STATIC_IMAGE);
::GetClientRect(hWnd,&stCR);
nCx = stCR.right - stCR.left;
nCy = stCR.bottom - stCR.top;
hDC = ::GetDC(hWnd);
StretchDIBits(hDC,stCR.left,stCR.top,nCx,nCy,0,0,m_nCameraCX,m_nCameraCY,m_pstBytes,m_pstBMI,DIB_RGB_COLORS,SRCCOPY);
}
But I can not see the bitmap. Even I put it in the OnPaint(). I still
can not see it.
If I add timer and add it in OnPaint() and called it in OnTimer(). I
can see it. why?