home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************/
- /* */
- /* TurboCAD for Windows */
- /* Copyright (c) 1993 - 2001 */
- /* International Microcomputer Software, Inc. */
- /* (IMSI) */
- /* All rights reserved. */
- /* */
- /******************************************************************/
-
- // InsSymb.cpp : Implementation of CInsSymb
- #include "stdafx.h"
- #include "InsTool.h"
- #include "InsSymb.h"
- #include "TDialog.h"
-
- /////////////////////////////////////////////////////////////////////////////
- //const IID IID_Tool = {0x6A48112C,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}};
- //const IID IID_IApplication = {0x6A481101,0xE531,0x11CF,{0xA1,0x15,0x00,0xA0,0x24,0x15,0x8D,0xAF}};
-
-
- // CInsSymb
-
- STDMETHODIMP CInsSymb::InterfaceSupportsErrorInfo(REFIID riid)
- {
- static const IID* arr[] =
- {
- &IID_ITurboCADTool,
- };
- for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
- {
- if (InlineIsEqualGUID(*arr[i],riid))
- return S_OK;
- }
- return S_FALSE;
- }
-
-
- STDMETHODIMP CInsSymb::get_ClassID(BSTR* retval)
- {
- HRESULT hRes = E_FAIL;
- LPOLESTR olestr = NULL;
-
- try
- {
- *retval = NULL;
-
- hRes = ::StringFromCLSID(CLSID_InsSymb, &olestr);
- CHECK_HRESULT(hRes)
-
- *retval = ::SysAllocString(olestr);
-
- hRes = S_OK;
- }
- catch (...)
- {
-
- TRACE_EXCEPTION("CInsSymb::get_ClassID")
- _clearfp();
- }
-
- if (olestr != NULL)
- CoTaskMemFree(olestr);
-
- return hRes;
- }
-
- STDMETHODIMP CInsSymb::get_Description( BSTR* retval)
- {
- HRESULT hRes = E_FAIL;
- CString strResult;
-
- try
- {
- *retval = NULL;
-
- CString strResult;
- strResult.LoadString(IDS_DESCRIPTION);
- *retval = strResult.AllocSysString();
- hRes = S_OK;
- }
- catch (...)
- {
- TRACE_EXCEPTION("CInsSymb::get_Description")
- _clearfp();
- }
- return hRes;
- }
-
- /* ITurboCADTool methods: */
- STDMETHODIMP CInsSymb::GetToolInfo(VARIANT FAR* CommandNames,
- VARIANT FAR* MenuCaptions,
- VARIANT FAR* StatusPrompts,
- VARIANT FAR* ToolTips,
- VARIANT FAR* Enabled,
- VARIANT FAR* WantsUpdates,
- long FAR* retval)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
-
- HRESULT hRes = E_FAIL;
-
- SAFEARRAYBOUND bound = {NUM_TOOLS, 0};
-
- CString cstrText;
- CString cstrTextTemp;
-
- BSTR bstrCommandName = NULL;
- BSTR bstrMenuCaption = NULL;
- BSTR bstrStatusPrompt = NULL;
- BSTR bstrToolTip = NULL;
-
- BOOL bEnabled = TRUE;
- BOOL bWantsUpdates = TRUE;
-
-
- long lIndicies = 0;
- try
- {
-
- hRes = SafeArrayRedim(CommandNames->parray, &bound);
- CHECK_HRESULT(hRes)
-
- hRes = SafeArrayRedim(MenuCaptions->parray, &bound);
- CHECK_HRESULT(hRes)
-
- hRes = SafeArrayRedim(StatusPrompts->parray, &bound);
- CHECK_HRESULT(hRes)
-
- hRes = SafeArrayRedim(ToolTips->parray, &bound);
- CHECK_HRESULT(hRes)
-
- hRes = SafeArrayRedim(Enabled->parray, &bound);
- CHECK_HRESULT(hRes)
-
- hRes = SafeArrayRedim(WantsUpdates->parray, &bound);
- CHECK_HRESULT(hRes)
-
- cstrText.LoadString (IDS_MAINMENU);
- cstrText.Insert(cstrText.GetLength (), '|');
- cstrTextTemp.LoadString (IDS_SUBMENU);
- cstrText.Insert(cstrText.GetLength (), cstrTextTemp);
- cstrText.Insert(cstrText.GetLength (), '|');
- cstrTextTemp.LoadString (IDS_MENUCAPTION);
- cstrText.Insert(cstrText.GetLength (), cstrTextTemp);
- cstrTextTemp.Empty ();
-
- bstrCommandName = cstrText.AllocSysString();
- hRes = SafeArrayPutElement(CommandNames->parray, &lIndicies, (void *)bstrCommandName);
- CHECK_HRESULT(hRes)
-
- cstrText.Empty ();
- cstrText.LoadString (IDS_MENUCAPTION);
- bstrMenuCaption = cstrText.AllocSysString();
- hRes = SafeArrayPutElement(MenuCaptions->parray, &lIndicies, (void *)bstrMenuCaption);
- CHECK_HRESULT(hRes)
-
- cstrText.Empty ();
- cstrText.LoadString (IDS_PROMT);
- bstrStatusPrompt = cstrText.AllocSysString();
- hRes = SafeArrayPutElement(StatusPrompts->parray, &lIndicies, (void *)bstrStatusPrompt);
- CHECK_HRESULT(hRes)
-
- cstrText.LoadString (IDS_TOOLTIPS);;
- bstrToolTip = cstrText.AllocSysString();
- hRes = SafeArrayPutElement(ToolTips->parray, &lIndicies, (void *)bstrToolTip);
- CHECK_HRESULT(hRes)
-
- hRes = SafeArrayPutElement(Enabled->parray, &lIndicies, (void *)&bEnabled);
- CHECK_HRESULT(hRes)
-
- hRes = SafeArrayPutElement(WantsUpdates->parray, &lIndicies, (void *)&bWantsUpdates);
- CHECK_HRESULT(hRes)
-
- *retval = NUM_TOOLS;
- }
- catch (...)
- {
- if (SUCCEEDED(hRes))
- hRes = E_FAIL;
- TRACE_EXCEPTION("CInsSymb::GetToolInfo")
- _clearfp();
- }
- return hRes;
- }
-
- STDMETHODIMP CInsSymb::CopyBitmap( VARIANT_BOOL LargeButtons, VARIANT_BOOL Monochrome, VARIANT_BOOL FAR* retval)
- {
- HRESULT hRes = E_FAIL;
- try
- {
- CHECK_HRESULT(hRes)
- hRes = S_OK;
- }
- catch (...)
- {
- TRACE_EXCEPTION("CInsSymb::CopyBitmap")
- _clearfp();
- }
- return hRes;
- }
-
- STDMETHODIMP CInsSymb::GetPicture( VARIANT_BOOL LargeButtons, VARIANT_BOOL Monochrome, IDispatch** retval)
- {
- HRESULT hRes = E_FAIL;
- try
- {
- CHECK_HRESULT(hRes)
- hRes = S_OK;
- }
- catch (...)
- {
- TRACE_EXCEPTION("CAALBTool::GetPicture")
- _clearfp();
- }
- return hRes;
- }
-
- STDMETHODIMP CInsSymb::Run( IDispatch* ThisTool, VARIANT_BOOL FAR* retval)
- {
- CWnd *pMainWnd = AfxGetMainWnd();
-
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- CInsToolApp *pApp = (CInsToolApp *)AfxGetApp();
-
- HRESULT hRes = E_FAIL;
-
- Tool *pThisTool = NULL;
- IApplication *pIApp = NULL;
-
- IGraphic *pIGr = NULL;
- Graphics *pGrs = NULL;
-
- IDrawing *pIDwg = NULL;
-
- Views *pVis = NULL;
- View *pVi = NULL;
-
- PickResult *pPickRes=NULL;
- PickEntry *pPickEnt=NULL;
-
- RegenMethods *pRegMets=NULL;
- RegenMethod *pIRegMet=NULL;
-
- COleVariant varAperture(0.2);
- COleVariant varItem;
- long lItem = 0;
- long lIndex = 0;
-
- COleVariant varOptional(varMissing);
- COleVariant varType((const long)imsiPolyline);
-
- VARIANT_BOOL varCopy = FALSE;
- VARIANT_BOOL varRetval = FALSE;
-
- long lID = 0;
-
- BSTR bstrType = NULL;
- CString strType;
-
- BSTR bstrDescription=NULL;
- CString strDescription;
-
- BSTR bstrName=NULL;
- CString strName;
-
- HCURSOR hOC = ::SetCursor(::LoadCursor(NULL,IDC_WAIT));
-
- try
- {
-
- hRes = ThisTool->QueryInterface(IID_Tool, (void **)&pThisTool);
- CHECK_HRESULT(hRes)
-
- hRes = pThisTool->get_Application(&pIApp);
- CHECK_HRESULT(hRes)
-
- CTDialog *pdlg = new CTDialog(this, pMainWnd, pThisTool);
- pdlg->Create(CTDialog::IDD, NULL /*pMainWnd*/);
-
- VARIANT_BOOL varRetval1 = false;
-
- hRes = UpdateToolStatus(ThisTool, &varRetval1, &varRetval1, &varRetval1);
- CHECK_HRESULT(hRes)
-
- pThisTool->Release();
- pThisTool = NULL;
-
- hRes = S_OK;
- }
- catch (...)
- {
- TRACE_EXCEPTION("CInsSymb::Run")
- _clearfp();
- }
-
- RELEASE(pThisTool)
- RELEASE(pIApp)
- ::SetCursor(hOC);
-
- return hRes;
- }
-
- STDMETHODIMP CInsSymb::UpdateToolStatus(IDispatch* ThisTool, VARIANT_BOOL FAR* Enabled, VARIANT_BOOL FAR* Checked, VARIANT_BOOL FAR* retval)
- {
- HRESULT hRes = E_FAIL;
-
- try
- {
- if(m_bRunned == TRUE)
- {
- (*Enabled) = false;
- }
- *retval = TRUE;
- hRes = S_OK;
- }
- catch (...)
- {
- TRACE_EXCEPTION("CInsSymb::UpdateToolStatus")
- _clearfp();
- }
-
- return hRes;
- }
-
- STDMETHODIMP CInsSymb::Initialize( IDispatch * ThisTool, VARIANT_BOOL FAR* retval)
- {
- HRESULT hRes = E_FAIL;
- try
- {
- m_pTCState = AfxGetModuleState();
- *retval = TRUE;
- hRes = S_OK;
- }
- catch (...)
- {
- TRACE_EXCEPTION("CInsSymb::Initialize")
- _clearfp();
- }
- return hRes;
- }
-