几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   SolidWorks二次开发 (http://www.dimcax.com/hust/forumdisplay.php?f=111)
-   -   How to get preview bitmaps? (http://www.dimcax.com/hust/showthread.php?t=1413)

huangyhg 2007-09-04 10:28 PM

How to get preview bitmaps?
 
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.

huangyhg 2007-09-04 10:34 PM

回复: 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.