ConvKmg2Dwg.cpp
上传用户:hell82222
上传日期:2013-12-19
资源大小:1872k
文件大小:4k
- // ConvKmg2Dwg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "FileSwitch.h"
- #include "ConvKmg2Dwg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CConvKmg2Dwg
- IMPLEMENT_DYNCREATE(CConvKmg2Dwg, CCmdTarget)
- CConvKmg2Dwg::CConvKmg2Dwg()
- {
- EnableAutomation();
-
- // To keep the application running as long as an OLE automation
- // object is active, the constructor calls AfxOleLockApp.
-
- AfxOleLockApp();
- }
- CConvKmg2Dwg::~CConvKmg2Dwg()
- {
- // To terminate the application when all objects created with
- // with OLE automation, the destructor calls AfxOleUnlockApp.
-
- AfxOleUnlockApp();
- }
- void CConvKmg2Dwg::OnFinalRelease()
- {
- // When the last reference for an automation object is released
- // OnFinalRelease is called. The base class will automatically
- // deletes the object. Add additional cleanup required for your
- // object before calling the base class.
- CCmdTarget::OnFinalRelease();
- }
- BEGIN_MESSAGE_MAP(CConvKmg2Dwg, CCmdTarget)
- //{{AFX_MSG_MAP(CConvKmg2Dwg)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- BEGIN_DISPATCH_MAP(CConvKmg2Dwg, CCmdTarget)
- //{{AFX_DISPATCH_MAP(CConvKmg2Dwg)
- DISP_FUNCTION(CConvKmg2Dwg, "BeginConverter", BeginConverter, VT_BOOL, VTS_BSTR)
- DISP_FUNCTION(CConvKmg2Dwg, "EndConverter", EndConverter, VT_BOOL, VTS_NONE)
- DISP_FUNCTION(CConvKmg2Dwg, "ConverterKmg2Dwg", ConverterKmg2Dwg, VT_BOOL, VTS_BSTR VTS_BSTR)
- DISP_FUNCTION(CConvKmg2Dwg, "GetProgressInfo", GetProgressInfo, VT_BOOL, VTS_PR8 VTS_PBSTR)
- //}}AFX_DISPATCH_MAP
- END_DISPATCH_MAP()
- // Note: we add support for IID_IConvKmg2Dwg to support typesafe binding
- // from VBA. This IID must match the GUID that is attached to the
- // dispinterface in the .ODL file.
- // {F2AAD484-E483-4C96-A865-CD4776307858}
- static const IID IID_IConvKmg2Dwg =
- { 0xf2aad484, 0xe483, 0x4c96, { 0xa8, 0x65, 0xcd, 0x47, 0x76, 0x30, 0x78, 0x58 } };
- BEGIN_INTERFACE_MAP(CConvKmg2Dwg, CCmdTarget)
- INTERFACE_PART(CConvKmg2Dwg, IID_IConvKmg2Dwg, Dispatch)
- END_INTERFACE_MAP()
- // {2848550E-02EB-448C-901D-CA7870DBA6CC}
- IMPLEMENT_OLECREATE(CConvKmg2Dwg, "FileSwitch.ConvKmg2Dwg", 0x2848550e, 0x2eb, 0x448c, 0x90, 0x1d, 0xca, 0x78, 0x70, 0xdb, 0xa6, 0xcc)
- /////////////////////////////////////////////////////////////////////////////
- // CConvKmg2Dwg message handlers
- extern CFileSwitchApp theApp;
- extern CStdioFile g_CensorialFile; //监察转换进度的文件
- extern int g_mode;
- BOOL CConvKmg2Dwg::BeginConverter(LPCTSTR strRegistryKey)
- {
- m_pProgress=new CProgressInfo;
- m_pCommand=new CCommandInfo;
- m_pConverter=new CDwgConverter(m_pCommand);
- m_pReader=new CKmgReader(m_pProgress,m_pCommand,m_pConverter);
- theApp.SetUserRegistryKey(strRegistryKey);
- return m_pReader->BeginConvert();
- }
- BOOL CConvKmg2Dwg::EndConverter()
- {
- BOOL bSuccess=m_pReader->EndConvert();
- delete m_pProgress;
- delete m_pCommand;
- delete m_pReader;
- delete m_pConverter;
- return bSuccess;
- }
- BOOL CConvKmg2Dwg::ConverterKmg2Dwg(LPCTSTR strKmgFilename, LPCTSTR strDwgFilename)
- {
- m_pCommand->m_strSourceName=strKmgFilename;
- m_pCommand->m_strAimName=strDwgFilename;
- // m_pCommand->m_hmainfrm=(HWND)hwnd;
- g_mode=0;
- //theApp.GetProfileInt("PARAMETER","CONVMODE",0);
- //if(g_mode!=1)
- //{
- // g_mode=0;
- //}
- //theApp.WriteProfileInt("PARAMETER","CONVMODE",0);
- _CONV_OPEN;
- BOOL bSucc=m_pReader->Parse();
- _CONV_CLOSE;
- return bSucc;
- }
- BOOL CConvKmg2Dwg::GetProgressInfo(double FAR* pdProgress, BSTR FAR* pstrProgressTip)
- {
- double dProgress;
- CString strProgressTip;
- if(m_pProgress==NULL)
- {
- return FALSE;
- }
- m_pProgress->GetProgressInfo(dProgress,strProgressTip);
- *pstrProgressTip=(BSTR FAR)(LPCTSTR)strProgressTip;
- *pdProgress=dProgress;
- return TRUE;
- }