![]() |
How to get preview bitmaps?
![]() GetPreviewBitmap.zip Updated: 6/15/2004 Size: 0.505 This sample code shows how to use SldWorks::GetPreviewBitmap in a C++ COM Addin. |
回复: 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; } |
所有的时间均为北京时间。 现在的时间是 06:15 AM. |