home *** CD-ROM | disk | FTP | other *** search
Wrap
/******************************************************************/ /* */ /* TurboCAD for Windows */ /* Copyright (c) 1993 - 2001 */ /* International Microcomputer Software, Inc. */ /* (IMSI) */ /* All rights reserved. */ /* */ /******************************************************************/ // TDialog.cpp : implementation file // #include <afxwin.h> #include "stdafx.h" #include "InsTool.h" #include "InsSymb.h" #include "ViewWnd.h" #include "TDialog.h" #include "TDialog1.h" #include "Dirdialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// BEGIN_MESSAGE_MAP(CTDialog, CDialog) //{{AFX_MSG_MAP(CTDialog) ON_BN_CLICKED(ID_CLOSE, OnClose) ON_BN_CLICKED(IDC_BROWSE, OnBrowse) ON_BN_CLICKED(IDC_MODIFY, OnModify) ON_BN_CLICKED(IDC_SPACEMODE, OnChangeSpaceMode) ON_BN_CLICKED(ID_INSERTSYMB, OnInsertsymb) ON_WM_SYSCOMMAND() //}}AFX_MSG_MAP END_MESSAGE_MAP() BEGIN_DISPATCH_MAP(CTDialog, CDialog) //{{AFX_DISPATCH_MAP(CTDialog) // NOTE - the ClassWizard will add and remove mapping macros here. DISP_FUNCTION(CTDialog, "MouseDown", MouseDown, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH VTS_DISPATCH VTS_I2 VTS_I4 VTS_I4 VTS_I4 VTS_PBOOL) DISP_FUNCTION(CTDialog, "MouseUp", MouseUp, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH VTS_DISPATCH VTS_I2 VTS_I4 VTS_I4 VTS_I4 VTS_PBOOL) DISP_FUNCTION(CTDialog, "MouseMove", MouseMove, VT_EMPTY, VTS_DISPATCH VTS_DISPATCH VTS_DISPATCH VTS_I4 VTS_I4 VTS_I4 VTS_PBOOL) DISP_FUNCTION(CTDialog, "DrawingBeforeClose", DrawingBeforeClose, VT_EMPTY, VTS_DISPATCH VTS_PBOOL) //}}AFX_DISPATCH_MAP END_DISPATCH_MAP() // Note: we add support for IID_ITDialog to support typesafe binding // from VBA. This IID must match the GUID that is attached to the // dispinterface in the .ODL file. BEGIN_INTERFACE_MAP(CTDialog, CDialog) INTERFACE_PART(CTDialog, IID_IAppEvents, Dispatch) END_INTERFACE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTDialog dialog CTDialog::CTDialog(CInsSymb* pTool, CWnd* pParent, /*=NULL*/Tool *pThisTool) : CDialog(CTDialog::IDD, pParent), m_dwEventConnection(0), m_dwEventMask(~0UL), m_pIApplication(NULL), m_FirstClick(FALSE), m_bDragging(FALSE), m_pDragGraphic(NULL), m_pTCADView(NULL), m_pThisTool(NULL), m_wndView(pTool) { EnableAutomation(); //{{AFX_DATA_INIT(CTDialog) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pTool = pTool; m_pTool->AddRef(); m_pTool->m_bRunned = TRUE; m_pThisTool = pThisTool; m_pThisTool->AddRef(); } void CTDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CTDialog) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } // CTDialog message handlers BOOL CTDialog::OnInitDialog() { CString cstrPropName; CString cstrInitPath; COleVariant varItem; COleVariant varVal; Properties *pProps = NULL; Property *pProp = NULL; HRESULT hRes = E_FAIL; BOOL bRet = FALSE; CDialog::OnInitDialog(); m_list.SubclassDlgItem( IDC_SYMBOLSLIST , this ); CSymbolsList *pList = (CSymbolsList *)GetDlgItem(IDC_SYMBOLSLIST); try { HMODULE hHdl = NULL; char path[256]; DWORD dBufSize = 256; DWORD dW = 0; hHdl = GetModuleHandle(NULL); dW = GetModuleFileName(hHdl, path, dBufSize); hHdl = NULL; cstrInitPath = path; cstrInitPath = cstrInitPath.Left(cstrInitPath.GetLength () - 10); // delete module name from path pList->RefreshFileList(cstrInitPath); CEdit *pPath = (CEdit *) GetDlgItem(IDC_EDITPATH); pPath->SetWindowText(cstrInitPath); CString selected; m_wndView.SubclassDlgItem(IDC_PREVIEW, this); CPreviewWnd *pViewWnd = (CPreviewWnd *)GetDlgItem(IDC_PREVIEW); if(pList->SetCurSel(0) != LB_ERR) { pList->GetText(0 ,(pList->m_cstrCurSelected)); pViewWnd->CreatePreview(); pViewWnd->DoPreview(); ConnectEvents(); } else { ConnectEvents(); } bRet = TRUE; } catch (...) { TRACE_EXCEPTION("CTDialog::OnInitDialog") _clearfp(); } return bRet; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CTDialog::OnClose() { if(m_dwEventConnection != 0) DisconectEvents(); CPreviewWnd *pViewWnd = (CPreviewWnd *)GetDlgItem(IDC_PREVIEW); pViewWnd->ClearAll(); m_pTool->m_bRunned = FALSE; if(m_pTool != NULL) { m_pTool->Release(); m_pTool = NULL; } if(m_pThisTool != NULL) { m_pThisTool->Release(); m_pThisTool = NULL; } CDialog::OnClose(); DestroyWindow(); } void CTDialog::OnSysCommand(UINT nID, LPARAM lParam ) { if (nID == SC_CLOSE) { if(m_dwEventConnection != 0) DisconectEvents(); CPreviewWnd *pViewWnd = (CPreviewWnd *)GetDlgItem(IDC_PREVIEW); pViewWnd->ClearAll(); m_pTool->m_bRunned = FALSE; if(m_pTool != NULL) { m_pTool->Release(); m_pTool = NULL; } if(m_pThisTool != NULL) { m_pThisTool->Release(); m_pThisTool = NULL; } } CDialog::OnSysCommand(nID, lParam ); } void CTDialog::OnModify() { CWnd *pMainWnd = AfxGetMainWnd(); CModifyDlg *pModifydlg = new CModifyDlg(m_pTool, pMainWnd); int i = pModifydlg->DoModal(); } void CTDialog::OnChangeSpaceMode() { CPreviewWnd *pViewWnd = (CPreviewWnd *)GetDlgItem(IDC_PREVIEW); AFX_MANAGE_STATE(m_pTool->m_pTCState); Properties *pProps = NULL; Property *pProp = NULL; VARIANT varVal;//(0L); varVal.vt = VT_I2; // TileMode - Property of drawing that store current drawing mode (PaperSpace or ModelSpace) // imsiModelSpace = 1, imsiPaperSpace = 0 CString cstrName("TileMode");//# Non-localizable string# BSTR bstrName = cstrName.AllocSysString(); VARIANT varItem; ::VariantInit(&varItem); varItem.vt = VT_BSTR; varItem.bstrVal = bstrName; try { if(pViewWnd->m_pPreviewDrawing != NULL) { HRESULT hRes = pViewWnd->m_pPreviewDrawing->get_Properties(&pProps); CHECK_HRESULT(hRes) hRes = pProps->get_Item(&varItem, &pProp); CHECK_HRESULT(hRes) pProp->get_Value(NULL, &varVal); if (varVal.iVal == 0) // cur drawing mode is paper space { varVal.iVal = 1; hRes = pProp->put_Value(NULL, &varVal); CHECK_HRESULT(hRes) } else // cur drawing mode is model space { varVal.iVal = 0; hRes = pProp->put_Value(NULL, &varVal); // switch the preview drawing to paper space CHECK_HRESULT(hRes) } pViewWnd->Invalidate(); hRes = pViewWnd->m_pPreviewView->ZoomToExtents(); CHECK_HRESULT(hRes) hRes = pViewWnd->m_pPreviewView->Refresh(); CHECK_HRESULT(hRes) ::VariantClear(&varItem); } } catch (...) { _clearfp(); TRACE_EXCEPTION("TDialog::OnChangeSpaceMode") } if (pProp != NULL) { pProp->Release(); pProp = NULL; } if (pProps != NULL) { pProps->Release(); pProps = NULL; } } void CTDialog::DrawingBeforeClose(LPDISPATCH WhichDrawing, BOOL FAR* Cancel) { *Cancel = FALSE; Drawings *pDrs = NULL; long n = 0; try { HRESULT hRes = m_pIApplication->get_Drawings(&pDrs); CHECK_HRESULT(hRes) hRes = pDrs->get_Count(&n); CHECK_HRESULT(hRes) if (n == 2) { if(m_dwEventConnection != 0) DisconectEvents(); CPreviewWnd *m_wndView = (CPreviewWnd *)GetDlgItem(IDC_PREVIEW); m_wndView->ClearAll(); m_pTool->m_bRunned = FALSE; CDialog::OnClose(); DestroyWindow(); } } catch (...) { _clearfp(); TRACE_EXCEPTION("TDialog::DrawingBeforeClose") } if (pDrs != NULL) { pDrs->Release(); pDrs = NULL; } } void CTDialog::MouseDown(LPDISPATCH WhichDrawing, LPDISPATCH WhichView, LPDISPATCH WhichWindow, short Button, long Shift, long X, long Y, IMSI_BOOL* pbCancel) { // do nothing on this event *pbCancel = FALSE; } void CTDialog::MouseUp(LPDISPATCH WhichDrawing, LPDISPATCH WhichView, LPDISPATCH WhichWindow, short Button, long Shift, long X, long Y, IMSI_BOOL* pbCancel) { *pbCancel = FALSE; HRESULT hRes = E_FAIL; CMerge merge; IDrawing *pIDwgTrg = NULL; Graphics *pGrs = NULL; COleVariant varOptional(varMissing); CPreviewWnd *pViewWnd = (CPreviewWnd *)GetDlgItem(IDC_PREVIEW); AFX_MANAGE_STATE(m_pTool->m_pTCState); try { if(m_pDragGraphic != 0) { pIDwgTrg = (IDrawing*)WhichDrawing; pIDwgTrg->AddRef(); hRes = merge.InitA(pViewWnd->m_pPreviewDrawing, pIDwgTrg); CHECK_HRESULT(hRes) hRes = merge.RunA(); CHECK_HRESULT(hRes) hRes = pIDwgTrg->get_Graphics(&pGrs); // get current drawing graphic collection CHECK_HRESULT(hRes) hRes = pGrs->AddGraphic(m_pDragGraphic, varOptional, varOptional); CHECK_HRESULT(hRes) hRes = merge.CorrectGraphic(m_pDragGraphic); CHECK_HRESULT(hRes) hRes = m_pDragGraphic->Update(); CHECK_HRESULT(hRes) pIDwgTrg->Release(); pIDwgTrg = NULL; CPoint point; point.x = X; point.y = Y; m_pTCADView = (View*) WhichView; m_pTCADView->AddRef(); EndDrag(point); hRes = m_pTCADView->Refresh(); CHECK_HRESULT(hRes) m_FirstClick = FALSE; } } catch (...) { _clearfp(); TRACE_EXCEPTION("TDialog::MouseUp") } if (m_pTCADView != NULL) { m_pTCADView->Release(); m_pTCADView = NULL; } if (pGrs != NULL) { pGrs->Release(); pGrs = NULL; } } void CTDialog::MouseMove(LPDISPATCH WhichDrawing, LPDISPATCH WhichView, LPDISPATCH WhichWindow, long Shift, long X, long Y, IMSI_BOOL* pbCancel) { *pbCancel = FALSE; CPoint point; point.x = X; point.y = Y; Graphics* GrsTmp = NULL;; Graphics* pPreviewGrs = NULL;; IGraphic* Gr1 = NULL; long c = 0; IDrawing *pIDwgTrg = NULL; Graphics *pGrs = NULL; View *pTCADCurrentView = NULL; try { if (m_FirstClick == TRUE)/// && m_bDragging != FALSE) { if(m_pTCADView != NULL) { m_pTCADView->Release(); } m_pTCADView = (View *)WhichView; m_pTCADView->AddRef(); CPreviewWnd *pPreview = (CPreviewWnd *) (GetDlgItem(IDC_PREVIEW)); COleVariant varItem = (1L); HRESULT hRes = pPreview->m_pPreviewDrawing->get_Graphics(&pPreviewGrs); CHECK_HRESULT(hRes) #ifdef _DEBUG hRes = pPreviewGrs->get_Count(&c); CHECK_HRESULT(hRes) #endif varItem = 0L; hRes = pPreviewGrs->get_Item(varItem, &Gr1); CHECK_HRESULT(hRes) // check if the graphic that we drag is empty hRes = Gr1->get_Graphics(&GrsTmp); CHECK_HRESULT(hRes) long b = 0; hRes = GrsTmp->get_Count(&b); CHECK_HRESULT(hRes) if (b == 0) //if it is empty then return; { GrsTmp->Release(); GrsTmp = NULL; Gr1->Release(); Gr1 = NULL; pPreviewGrs->Release(); pPreviewGrs = NULL; m_FirstClick = TRUE; return; } hRes = Gr1->Duplicate(&m_pDragGraphic); CHECK_HRESULT(hRes) m_pDragGraphic->Release(); m_pDragGraphic = NULL; hRes = pPreviewGrs->get_Count(&c); CHECK_HRESULT(hRes) varItem = c -1L; hRes = pPreviewGrs->Remove(&varItem, &m_pDragGraphic); CHECK_HRESULT(hRes) m_FirstClick = FALSE; BeginDrag(point); } else { if (m_pDragGraphic != NULL && !m_bDragging)/// aalb && (nFlags & MK_LBUTTON)) { if (!BeginDrag(point)) { m_pDragGraphic->Release(); m_pDragGraphic = NULL; } } else if (m_bDragging) { pTCADCurrentView = (View *)WhichView; pTCADCurrentView->AddRef(); if (pTCADCurrentView != m_pTCADView) // if view is changed (user drag symbol over another view(window)) then restart drag { m_pTCADView = pTCADCurrentView; pTCADCurrentView->Release(); pTCADCurrentView = NULL; RestartDrag(point); } Drag(point); } } } catch (...) { TRACE_EXCEPTION("CTDialog::OnMouseMove") _clearfp(); } if(GrsTmp != NULL) { GrsTmp->Release(); GrsTmp = NULL; } if(Gr1 != NULL) { Gr1->Release(); Gr1 = NULL; } if(pPreviewGrs != NULL) { pPreviewGrs->Release(); pPreviewGrs = NULL; } } void CTDialog::ConnectEvents() { HRESULT hRes = S_OK; if (m_dwEventConnection != 0) { return; } m_pIApplication = NULL; try { hRes = m_pThisTool->get_Application(&m_pIApplication); CHECK_HRESULT(hRes) if (m_pIApplication == NULL) return; IDispatch* pUnkEventSink = GetIDispatch(TRUE); UpdateData(TRUE); COleVariant var((long)m_dwEventMask); hRes = m_pIApplication->ConnectEvents(pUnkEventSink, &var, (long*)&m_dwEventConnection); if (FAILED(hRes)) return; } catch (...) { TRACE_EXCEPTION("CTDialog::ConnectEvents") _clearfp(); } } void CTDialog::DisconectEvents() { if (m_pIApplication == NULL || m_dwEventConnection == 0) return; try { HRESULT hRes = m_pIApplication->DisconnectEvents(m_dwEventConnection); if (FAILED(hRes)) { return; } m_pIApplication->Release(); // possibility problem m_pIApplication = NULL; m_dwEventConnection = 0; } catch (...) { TRACE_EXCEPTION("CTDialog::DisconectEvents") _clearfp(); } } BOOL CTDialog::BeginDrag(const CPoint& point) { BOOL bRes = FALSE; HRESULT hRes = E_FAIL; BoundingBox* Box = NULL; IVertex* vMax = NULL; IVertex* vMin = NULL; double x, y, x1, y1; if (m_pTCADView == NULL) return bRes; try { VariantClear(&m_dragOutline); SAFEARRAYBOUND bound; bound.cElements = 0; bound.lLbound = 0; m_dragOutline.vt = VT_ARRAY|VT_R8; m_dragOutline.parray = ::SafeArrayCreate(VT_R8, 1, &bound); hRes = m_pDragGraphic->CreateDragOutline(&m_dragOutline); CHECK_HRESULT(hRes); m_bDragging = TRUE; m_pDragGraphic->put_Visible(FALSE); VARIANT varState; varState.vt = VT_I4; varState.lVal = imsiDragBegin; hRes = m_pDragGraphic->CalcBoundingBox(NULL, &Box); CHECK_HRESULT(hRes) hRes = Box->get_Max(&vMax); CHECK_HRESULT(hRes) hRes = Box->get_Min(&vMin); CHECK_HRESULT(hRes) hRes = vMax->get_X(&x); CHECK_HRESULT(hRes) hRes = vMax->get_Y(&y); CHECK_HRESULT(hRes) hRes = vMin->get_X(&x1); CHECK_HRESULT(hRes) hRes = vMin->get_Y(&y1); CHECK_HRESULT(hRes) x = x1 + (x - x1)/2; y = y1 + (y - y1)/2; hRes = m_pTCADView->ViewToScreen(x, y, &x1, &y1, NULL); CHECK_HRESULT(hRes) hRes = m_pTCADView->DragOutline(&m_dragOutline, x1, y1, &varState); CHECK_HRESULT(hRes) varState.lVal = imsiDragContinue; hRes = m_pTCADView->DragOutline(&m_dragOutline, point.x, point.y, &varState); CHECK_HRESULT(hRes) bRes = TRUE; } catch (...) { TRACE_EXCEPTION("CTDialog::BeginDrag") _clearfp(); } if (vMin != NULL) { vMin->Release(); vMin = NULL; } if (vMax != NULL) { vMax->Release(); vMax = NULL; } if (Box != NULL) { Box->Release(); Box = NULL; } return bRes; } BOOL CTDialog::Drag(const CPoint& point) { BOOL bRes = FALSE; if (m_pTCADView == NULL) return bRes; try { VARIANT varState; varState.vt = VT_I4; varState.lVal = imsiDragContinue; HRESULT hRes = m_pTCADView->DragOutline(&m_dragOutline, point.x, point.y, &varState); CHECK_HRESULT(hRes) bRes = TRUE; } catch (...) { TRACE_EXCEPTION("CTDialog::Drag") _clearfp(); } return bRes; } BOOL CTDialog::EndDrag(const CPoint& point) { BOOL bRes = FALSE; m_bDragging = FALSE; IMatrix *pMat = NULL; if (m_pTCADView == NULL || m_pDragGraphic == NULL) return bRes; IDrawing *pIDwg = NULL; Properties *pProps = NULL; Property *pProp = NULL; try { VARIANT varState; varState.vt = VT_I4; varState.lVal = imsiDragEnd; HRESULT hRes = m_pTCADView->DragOutline(&m_dragOutline, point.x, point.y, &varState); CHECK_HRESULT(hRes) VariantClear(&m_dragOutline); double dx, dy, dz; dx = dy = dz = 0; double dxWorld, dyWorld, dzWorld; dxWorld = dyWorld = dzWorld = 0; hRes = m_pTCADView->ScreenToView(point.x, point.y, &dx, &dy); CHECK_HRESULT(hRes) dxWorld = dx; dyWorld = dy; VARIANT var; var.vt = VT_ERROR; var.scode = DISP_E_PARAMNOTFOUND; CString cstrName("TileMode");//# Non-localizable string# BSTR bstrName = cstrName.AllocSysString(); VARIANT varItem; ::VariantInit(&varItem); varItem.vt = VT_BSTR; varItem.bstrVal = bstrName; hRes = m_pTCADView->get_Drawing(&pIDwg); CHECK_HRESULT(hRes) hRes = pIDwg->get_Properties(&pProps); CHECK_HRESULT(hRes) hRes = pProps->get_Item(&varItem, &pProp); CHECK_HRESULT(hRes) COleVariant varVal; varVal.vt = VT_I2; hRes = pProp->get_Value(NULL, &varVal); CHECK_HRESULT(hRes) if(varVal.iVal == imsiModelSpace) //ModelSpace { hRes = m_pTCADView->ViewToWorld(dx, dy, dz, &dxWorld, &dyWorld, &dzWorld); CHECK_HRESULT(hRes) } hRes = m_pDragGraphic->MoveAbsolute(dxWorld, dyWorld, 0, &var, &var, &var, &pMat); CHECK_HRESULT(hRes) hRes = m_pDragGraphic->put_Visible(TRUE); CHECK_HRESULT(hRes) bRes = TRUE; } catch (...) { TRACE_EXCEPTION("CTDialog::EndDrag") _clearfp(); } if(pMat != NULL) { pMat->Release(); pMat = NULL; } if (m_pDragGraphic != NULL) { m_pDragGraphic->Release(); m_pDragGraphic = NULL; } if (pProp != NULL) { pProp->Release(); pProp = NULL; } if (pProps != NULL) { pProps->Release(); pProps = NULL; } if (pIDwg != NULL) { pIDwg->Release(); pIDwg = NULL; } return bRes; } BOOL CTDialog::RestartDrag(const CPoint& point) { try { m_bDragging = FALSE; VARIANT varState; varState.vt = VT_I4; varState.lVal = imsiDragEnd; HRESULT hRes = m_pTCADView->DragOutline(&m_dragOutline, point.x, point.y, &varState); CHECK_HRESULT(hRes) VariantClear(&m_dragOutline); BeginDrag(point); } catch (...) { TRACE_EXCEPTION("CTDialog::RestartDrag") _clearfp(); } return TRUE; } void CTDialog::OnBrowse() { CSymbolsList *pList = (CSymbolsList *)GetDlgItem(IDC_SYMBOLSLIST); CPreviewWnd *pViewWnd = (CPreviewWnd *)GetDlgItem(IDC_PREVIEW); CEdit *pPath = (CEdit *) GetDlgItem(IDC_EDITPATH); CDirDialog* pDirDlg = new CDirDialog; pDirDlg->m_strTitle.LoadString(IDS_STRING104); pPath->GetWindowText(pDirDlg->m_strSelDir); CString strtmp; pPath->GetWindowText(strtmp); int i = pDirDlg->DoBrowse (m_hWnd); if(i == 0) return; HCURSOR hOC = ::SetCursor(::LoadCursor(NULL,IDC_WAIT)); if (strtmp != pDirDlg->m_strPath) { pPath->SetWindowText ((LPCTSTR) pDirDlg->m_strPath); pViewWnd->ClearAll (); pViewWnd->Invalidate (); pList->RefreshFileList(pDirDlg->m_strPath); if(pList->SetCurSel(0) != LB_ERR) { pList->GetText(0 ,(pList->m_cstrCurSelected)); pViewWnd->CreatePreview(); pViewWnd->DoPreview(); } } ::SetCursor(hOC); } void CTDialog::OnInsertsymb() { HRESULT hRes = E_FAIL; IGraphic *pIGr = NULL; IGraphic *pIGrTmp = NULL; IDrawing *pActDr = NULL; Graphics *pPreviewGrs = NULL; Graphics *pGrs = NULL; View *pActView = NULL; COleVariant varItem = (0L); COleVariant varOptional(varMissing); CMerge merge; try { CPreviewWnd *pPreview = (CPreviewWnd *)GetDlgItem(IDC_PREVIEW); if (m_pIApplication) { hRes = m_pIApplication->get_ActiveDrawing(&pActDr); if (SUCCEEDED(hRes) && pActDr) { hRes = pActDr->get_Graphics(&pGrs); if (SUCCEEDED(hRes) && pGrs) { if (pPreview->m_pPreviewDrawing) { hRes = pPreview->m_pPreviewDrawing->get_Graphics(&pPreviewGrs); if (SUCCEEDED(hRes) && pPreviewGrs) { hRes = pPreviewGrs->get_Item(&varItem, &pIGrTmp); if (SUCCEEDED(hRes) && pIGrTmp) { hRes = pIGrTmp->Duplicate(&pIGr); CHECK_HRESULT(hRes) RELEASE(pIGr) RELEASE(pIGrTmp) long n; n = 0; hRes = pPreviewGrs->get_Count(&n); if (SUCCEEDED(hRes)) { varItem = n -1L; } hRes = pPreviewGrs->Remove(&varItem, &pIGr); CHECK_HRESULT(hRes) hRes = merge.InitA(pPreview->m_pPreviewDrawing, pActDr); CHECK_HRESULT(hRes) hRes = merge.RunA(); CHECK_HRESULT(hRes) hRes = pIGr->put_ID(0); hRes = pGrs->AddGraphic(pIGr, varOptional, varOptional); CHECK_HRESULT(hRes) hRes = merge.CorrectGraphic(pIGr); CHECK_HRESULT(hRes) hRes = pIGr->Update(); CHECK_HRESULT(hRes) RELEASE(pIGr); RELEASE(pIGrTmp) hRes = pActDr->get_ActiveView(&pActView); if (SUCCEEDED(hRes) && pActView) { pActView->Refresh(); RELEASE(pActView); } } RELEASE(pPreviewGrs); } } RELEASE(pGrs) } RELEASE(pActDr) } } } catch(...) { TRACE("void TDialog::OnInsertsymb() "); } }