|
/***************************************************************************/
/* NOTE: */
/* This document is copyright (c) by Oz Solomonovich. All non-commercial */
/* use is allowed, as long as this document is not altered in any way, and */
/* due credit is given. */
/***************************************************************************/
// Commands.cpp : implementation file
//
#include "stdafx.h"
#include "LineCount.h"
#include "Commands.h"
#include "MainDlg.h"
#include "Parser.h"
#include "ResultsDlg.h"
#include "ExtrnSrc\AddInComm.h"
#include "ExtrnSrc\WWhizInterface.h"
#include "ExtrnSrc\WWhizInterfaceLoader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
WWhizInterface *g_pWWhizInteface = NULL;
/////////////////////////////////////////////////////////////////////////////
// CCommands
CCommands::CCommands()
{
m_pApplication = NULL;
m_pWWhizInt = NULL;
}
CCommands::~CCommands()
{
ASSERT (m_pApplication != NULL);
m_pApplication->Release();
if (m_pWWhizInt)
WWhizInterfaceDestroy();
}
void CCommands::SetApplicationObject(IApplication* pApplication)
{
// This function assumes pApplication has already been AddRef'd
// for us, which CDSAddIn did in its QueryInterface call
// just before it called us.
m_pApplication = pApplication;
}
/////////////////////////////////////////////////////////////////////////////
// CCommands methods
HRESULT CCommands::LCCmd(int iCmd)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
VERIFY_OK(m_pApplication->EnableModeless(VARIANT_FALSE));
if (!m_pWWhizInt)
{
// load the interface
m_pWWhizInt = WWhizInterfaceCreate(AfxGetInstanceHandle(),
m_pApplication);
// no luck? notify the user:
if (m_pWWhizInt == NULL)
{
AfxMessageBox(IDS_ERR_WWHIZINT, MB_OK | MB_ICONSTOP);
goto out;
}
g_pWWhizInteface = m_pWWhizInt;
}
switch (iCmd)
{
case 1:
{
CMainDlg dlg(m_pWWhizInt);
dlg.DoModal();
break;
}
case 2:
{
proj_stats *pStats;
if ((pStats = CountLines(m_pWWhizInt)) != NULL)
{
// display results
{
CResultsDlg dlg(pStats, m_pWWhizInt);
dlg.DoModal();
delete pStats;
}
}
break;
}
}
out:
VERIFY_OK(m_pApplication->EnableModeless(VARIANT_TRUE));
return S_OK;
}
STDMETHODIMP CCommands::LC_Console()
{
return LCCmd(1);
}
STDMETHODIMP CCommands::LC_Go()
{
return LCCmd(2);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here