|
楼主 |
发表于 2007-9-4 22:34:00
|
显示全部楼层
回复: How to get preview bitmaps?
BOOL CMyDialog::ShowConfigPreview()
{
CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_CONFIG_NAMES);
if ( !pCombo )
return FALSE;
int nIndex = pCombo->GetCurSel();
if ( nIndex == LB_ERR )
return FALSE;
CString strConfigName;
int nLen;
nLen = pCombo->GetLBTextLen( nIndex );
pCombo->GetLBText( nIndex, strConfigName.GetBuffer(nLen) );
strConfigName.ReleaseBuffer();
if ( strConfigName.IsEmpty() )
return FALSE;
CString strFilePath;
GetDlgItemText(IDC_FILE_PATH , strFilePath);
if ( strFilePath.IsEmpty() )
return FALSE;
BSTR bstrFilePath = strFilePath.AllocSysString();
BSTR bstrConfigName = strConfigName.AllocSysString();
IDispatch* pDisp = NULL;
HRESULT hres = m_iSldWorks->GetPreviewBitmap ( bstrFilePath , bstrConfigName , &pDisp );
if ( hres != S_OK || NULL == pDisp )
{
AfxMessageBox(_T("no preview for selected config"));
return FALSE;
}
IPictureDisp* pPictureDispatch = NULL;
hres = pDisp->QueryInterface(IID_IPictureDisp,(void**)&pPictureDispatch);
if ( NULL == pPictureDispatch )
{
return FALSE;
}
LPPICTURE pPict = NULL;
CPictureHolder holder;
holder.SetPictureDispatch(pPictureDispatch);
pPict = holder.m_pPict;
CPicture* pic = new CPicture();
pic->SetPicture(pPict);
m_wndPict.SetPicture(pic);
m_wndPict.Invalidate();
return TRUE;
} |
|