Click here to Skip to main content
15,881,882 members
Articles / Programming Languages / C++

Locking shareware functions

Rate me:
Please Sign up or sign in to vote.
2.00/5 (13 votes)
18 Sep 2003CPOL1 min read 74K   801   33  
This article describes how to lock some functions in a shareware product. Users can unlock them only after obtaining keyfile
// shwcodeDoc.cpp : implementation of the CShwcodeDoc class
//

#include "stdafx.h"
#include "shwcode.h"

#include "shwcodeDoc.h"
#include "shwcodeView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CShwcodeDoc

IMPLEMENT_DYNCREATE(CShwcodeDoc, CDocument)

BEGIN_MESSAGE_MAP(CShwcodeDoc, CDocument)
	//{{AFX_MSG_MAP(CShwcodeDoc)
	ON_COMMAND(ID_VIEW_PATTERN1, OnViewPattern1)
	ON_COMMAND(ID_VIEW_PATTERN2, OnViewPattern2)
	ON_COMMAND(ID_VIEW_LOCKEDPATTERN, OnViewLockedpattern)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CShwcodeDoc construction/destruction

CShwcodeDoc::CShwcodeDoc()
{
	// TODO: add one-time construction code here

}

CShwcodeDoc::~CShwcodeDoc()
{
}

BOOL CShwcodeDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CShwcodeDoc serialization

void CShwcodeDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CShwcodeDoc diagnostics

#ifdef _DEBUG
void CShwcodeDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CShwcodeDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CShwcodeDoc commands

void CShwcodeDoc::OnViewPattern1() 
{
	CShwcodeView*pv=NULL;
	pv=(CShwcodeView*)GetPatternView();
	if(!pv) return;
	pv->SetDrawMode(1);
	pv->RedrawWindow();
	
}

void CShwcodeDoc::OnViewPattern2() 
{
	CShwcodeView*pv=NULL;
	pv=(CShwcodeView*)GetPatternView();
	if(!pv) return;
	pv->SetDrawMode(2);
	pv->RedrawWindow();
	
}

void CShwcodeDoc::OnViewLockedpattern() 
{
	CShwcodeView*pv=NULL;
	pv=(CShwcodeView*)GetPatternView();
	if(!pv) return;
	pv->SetDrawMode(3);
	pv->RedrawWindow();
	
}

DWORD CShwcodeDoc::GetPatternView()
{
	POSITION pos=this->GetFirstViewPosition();
	CView*pv=this->GetNextView(pos);
	return (DWORD)pv;

}

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
Software Developer
Russian Federation Russian Federation
Professional Windows/Java Mobile/Web-applications developer since 2000.

Comments and Discussions