Click here to Skip to main content
15,884,388 members
Articles / Programming Languages / C++

Project Line Counter Add-In v2.10 for VS.NET and VC6

Rate me:
Please Sign up or sign in to vote.
4.92/5 (38 votes)
29 Jun 2003 447.8K   5.3K   142  
Get statistics about your source code with a click of a button
/***************************************************************************/
/* 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

/////////////////////////////////////////////////////////////////////////////
// CCommands

CCommands::CCommands()
{
    m_pApplication = NULL;
    m_pWWhizInt    = NULL;
}

CCommands::~CCommands()
{
    ASSERT (m_pApplication != NULL);
    m_pApplication->Release();

    if (m_pWWhizInt)
        WWhizDestroy();
}

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 = WWhizCreate(AfxGetInstanceHandle(), m_pApplication);

        // no luck? notify the user:
        if (m_pWWhizInt == NULL) 
        {
            AfxMessageBox(IDS_ERR_WWHIZINT, MB_OK | MB_ICONSTOP);
            goto out;
        }
    }

    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.

License

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


Written By
Experion
Canada Canada
You may know Oz from his WndTabs days. Oz has long since left client side development to work on web technologies and to consult in the R&D management field.

Comments and Discussions