wince6图片绘制时出现问题!!
void CYY_Wince1Dlg::DrawPicToHDC(CString p)
{
CDC *pDC;
CRect rc;
GetDlgItem(IDC_EDIT1)->GetClientRect(rc);
pDC=GetDlgItem(IDC_EDIT1)->GetDC();
hdcMem = *pDC;//added by kent
rcMemDC = rc;//added by kent
IImage *m_pImage;
IImagingFactory *m_pImagingFactory;
HRESULT hr;
hr=CoInitializeEx(NULL,COINIT_MULTITHREADED);
hr=CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory,(void**)&m_pImagingFactory);
hr=m_pImagingFactory->CreateImageFromFile(p,&m_pImage);
//hr=m_pImage->Draw(pDC->m_hDC,&rc,NULL);
//kent added -----------------------------
ImageInfo imageInfo;
m_pImage->GetImageInfo(&imageInfo);
hdcMem = CreateCompatibleDC(*pDC);
rcMemDC = {0,0,imageInfo.Width,imageInfo.Height};
hr=m_pImage->Draw(hdcMem.GetSafeHdc(),&rcMemDC,NULL);
pDstRect = &rcMemDC;
pSrcRect = &rcMemDC;
StretchBlt(*pDC, pDstRect->left,pDstRect->top,pDstRect->right -pDstRect->left, pDstRect->bottom - pDstRect->top, hdcMem, pSrcRect->left, pSrcRect->top, pSrcRect->right - pSrcRect->left, pSrcRect->bottom - pSrcRect->top, SRCCOPY);//向窗口推送
//end kent added -------------------------
}
错误信息:
1>.\YY_Wince1Dlg.cpp(103) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'HDC' (or there is no acceptable conversion)
1> F:\VS2005\VC\ce\atlmfc\include\afxwin.h(1071): could be 'CDC &CDC::operator =(const CDC &)'
1> while trying to match the argument list '(CDC, HDC)'
1>.\YY_Wince1Dlg.cpp(104) : error C2059: syntax error : '{'
1>.\YY_Wince1Dlg.cpp(104) : error C2143: syntax error : missing ';' before '{'
1>.\YY_Wince1Dlg.cpp(104) : error C2143: syntax error : missing ';' before '}' wince,嵌入式,VS2005 WinCE
[解决办法]
rcMemDC = {0,0,imageInfo.Width,imageInfo.Height};
什么意思?
[解决办法]
晕,应该是hdcMem.CreateCompatibleDC(pDC),你那样是HDC类型了