Click here to Skip to main content
15,881,559 members
Articles / Desktop Programming / MFC

A PIC C Code Wizard

Rate me:
Please Sign up or sign in to vote.
4.94/5 (27 votes)
5 May 2003CPOL5 min read 156.1K   7.9K   46  
Creates C code templates for PIC microcontrollers. The default templates are for use with the Hi-Tech (tm) PICC compiler.
// Documentation.cpp : implementation file
//

#include "stdafx.h"
#include "piccpc.h"
#include "Documentation.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDocumentation property page

IMPLEMENT_DYNCREATE(CDocumentation, CPropertyPage)

CDocumentation::CDocumentation() : CPropertyPage(CDocumentation::IDD)
{
	//{{AFX_DATA_INIT(CDocumentation)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CDocumentation::~CDocumentation()
{
}

void CDocumentation::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDocumentation)
	DDX_Control(pDX, IDC_DOC_INFO, m_sDOCInfo);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDocumentation, CPropertyPage)
	//{{AFX_MSG_MAP(CDocumentation)
	ON_BN_CLICKED(IDC_USE_HTML_HELP, OnUseHtmlHelp)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDocumentation message handlers

BOOL CDocumentation::OnKillActive() 
{
	PICInfo.bDOCUseHTML = IsDlgButtonChecked( IDC_USE_HTML );
	PICInfo.bDOCUseHTMLHelp = IsDlgButtonChecked( IDC_USE_HTML_HELP );
	PICInfo.bDOCUseRTF = IsDlgButtonChecked( IDC_USE_RTF );
	PICInfo.bDOCUseLaTeX = IsDlgButtonChecked( IDC_USE_LATEX );
	return CPropertyPage::OnKillActive();
}

BOOL CDocumentation::OnSetActive() 
{
	CheckDlgButton( IDC_USE_HTML, PICInfo.bDOCUseHTML );
	CheckDlgButton( IDC_USE_HTML_HELP, PICInfo.bDOCUseHTMLHelp );
	CheckDlgButton( IDC_USE_LATEX, PICInfo.bDOCUseLaTeX );
	CheckDlgButton( IDC_USE_RTF, PICInfo.bDOCUseRTF );
	return CPropertyPage::OnSetActive();
}

BOOL CDocumentation::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	m_sDOCInfo.SetWindowText( "- Source code is documented to support Doxygen"
		" as the documentation system:\n"
		"\thttp://www.stack.nl/~dimitri/doxygen/index.html\n\n"
		"- To support HTML Help format, download the HTML Help Workshop from:\n"
		"\thttp://www.microsoft.com/office/ork/xp/appndx/appa06.htm\n\n"
		"- To support LaTeX format, you can download MiKTeX from:\n"
		"\thttp://www.miktex.org\n"
		"\tLaTeX format will create a PDF version." );

	CFileFind ff;
	if ( !ff.FindFile(PICInfo.sHHCPath) ) {
		PICInfo.sHHCPath[0] = NULL;
	}
	CString s;
	GetDlgItemText( IDC_USE_HTML_HELP, s );
	if ( PICInfo.sHHCPath[0] == NULL ) {
		s += sSPECIFY;
		SetDlgItemText( IDC_USE_HTML_HELP, s );
	}
	else {
		s += " [";
		s += PICInfo.sHHCPath;
		s += "]";
		SetDlgItemText( IDC_USE_HTML_HELP, s );
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDocumentation::OnUseHtmlHelp() 
{
	if ( IsDlgButtonChecked(IDC_USE_HTML_HELP) ) {
		if ( PICInfo.sHHCPath[0] == NULL ) {
			CFileDialog fd(TRUE,NULL,"hhc.exe");
			char cd[MAX_PATH];
			GetCurrentDirectory( MAX_PATH, cd );
			int r = fd.DoModal();
			if ( IDOK == r ) {
				AfxGetApp()->WriteProfileString( SETTINGS, HHCPATH, fd.GetPathName() );
				CString s;
				GetDlgItemText( IDC_USE_HTML_HELP, s );
				s.Replace( sSPECIFY, "" );
				SetDlgItemText( IDC_USE_HTML_HELP, s );
			}
			else {
				CheckDlgButton( IDC_USE_HTML_HELP, 0 );
			}
			SetCurrentDirectory( cd );
		}
	}
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Delphi
United States United States
Carlos Buelna works in the automotive industry.

Comments and Discussions