奇怪!高手看过来!
RECT rect;
BITMAP bm;
HBITMAP hBitmap;
HDC hSrcDC;
HDC hDesDC;
CWnd *hwnd;
hwnd = GetDlgItem(IDC_PIC);
hDesDC = hwnd->GetDC()->m_hDC;
hSrcDC = CreateCompatibleDC(hDesDC);
hBitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),"e:\\SWPBMP\\default.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hBitmap, sizeof BITMAP, &bm);
SelectObject(hSrcDC, hBitmap);
hwnd->GetClientRect(&rect);
::SetStretchBltMode(hDesDC,COLORONCOLOR);
::StretchBlt(hDesDC, rect.left, rect.top, rect.right,rect.bottom, hSrcDC, 0, 0, bm.bmWidth, bm.bmHeight,+SRCCOPY);
UpdateData(false);
这段程序在BOOL CXubotestDlg::OnInitDialog()中不能显示图像。
而在void CXubotestDlg::OnButton1()中则可以。
高手解释解释。