这程序的窗口是个CView类或者继承的视图类吧,绘图都在OnDraw函数里,使用CDC类可以很容易绘图,你能画一个,应该可以画另一个。
我有丰富的VC代码,需要Q我 251700159
给你一个 使用IPICTURE的COM接口显示图片 的例子
void CArEditorView::OnAddPicture()
{
CFileDialog dlg(1,"*.*",NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ENABLESIZING|
OFN_FILEMUSTEXIST,
"(*.JPG)|*.JPG|(*.GIF)|*.GIF|(*.BMP)|*.BMP|",this);
if(dlg.DoModal()==IDCANCEL)
return;
str=dlg.GetPathName();
// 显示图片
IPicture *pPic;
IStream *pStm;
CFileStatus fstatus;
CFile file;
LONG cb;
if (file.Open(t,CFile::modeRead)&&file.GetStatus(t,
fstatus)&&
((cb = fstatus.m_size) != -1))
{
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cb);
LPVOID pvData = NULL;
if (hGlobal != NULL)
{
if ((pvData = GlobalLock(hGlobal)) != NULL)
{
file.Read(pvData, cb);
GlobalUnlock(hGlobal);
CreateStreamOnHGlobal(hGlobal, TRUE, &pStm);
if(SUCCEEDED(OleLoadPicture(pStm,fstatus.m_size,TRUE,IID_IPicture,(LPVOID*
)&pPic)))
{
OLE_XSIZE_HIMETRIC hmWidth;
OLE_YSIZE_HIMETRIC hmHeight;
pPic->get_Width(&hmWidth);
pPic->get_Height(&hmHeight);
double fX,fY;
fX = (double)pDC->GetDeviceCaps(HORZRES)*(double)hmWidth/
((double)pDC->GetDeviceCaps(HORZSIZE)*100.0);
fY = (double)pDC->GetDeviceCaps(VERTRES)*(double)hmHeight/
((double)pDC->GetDeviceCaps(VERTSIZE)*100.0);
if(FAILED(pPic->Render(*pDC,100,100,200,200,0,hmHeight,
hmWidth,-hmHeight,NULL)))
AfxMessageBox("Failed To Render The picture!");
pPic->Release();
}
else
AfxMessageBox("Error Loading Picture From Stream!");
}
}
}
else
AfxMessageBox("Can't Open Image File!");
}