Click here to Skip to main content
15,884,986 members
Articles / Desktop Programming / ATL

ATL COM Shared Add Ins Using C++ - The Easy Way

Rate me:
Please Sign up or sign in to vote.
4.33/5 (4 votes)
5 Mar 2007CPOL27 min read 77.4K   1.5K   32  
ATL COM Shared Add Ins Using C++ - The Easy Way
// WordFind.cpp : Implementation of CWordFind

#include "stdafx.h"
#include "WordFind.h"
#include "CRange.h"


// CWordFind
CWordFind::CWordFind( CDocument0* poDocument )
{
	m_poDocument = poDocument;
	m_lWordIndex = 1;
	m_oWords = poDocument->get_Words();
	m_lTotalNumberOfWords = m_oWords.get_Count();
}

CWordFind::~CWordFind()
	{
	}

LRESULT CWordFind::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		CAxDialogImpl<CWordFind>::OnInitDialog(uMsg, wParam, lParam, bHandled);
		bHandled = TRUE;
		m_cWord.Attach( GetDlgItem( IDC_WORD ) );
		return 1;  // Let the system set the focus
	}
	
LRESULT CWordFind::OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
	{
		EndDialog(wID);
		return 0;
	}

LRESULT CWordFind::OnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
	{
		EndDialog(wID);
		return 0;
	}

LRESULT CWordFind::OnBnClickedFind(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: Add your control notification handler code here
	CString text;
	m_cWord.GetWindowText( text );
	while ( m_lWordIndex <= m_lTotalNumberOfWords )
	{
		CRange oRange = m_oWords.Item( m_lWordIndex );
		m_lWordIndex++;
		CString word = oRange.get_Text();
		word.TrimRight();
		if ( text == word )
		{ 
			oRange.Select();
			return 0; 
		}
	}
	::MessageBox( NULL, text + " Not Found", "Not Found", MB_OK|MB_ICONSTOP );
	return 0;
}

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 Dotric Pty Ltd
Australia Australia
Doug graduated from Deakin University Geelong, Victoria, Australia with a Bachelor of Engineering.

Early in his career, Doug worked on an automated system for testing telephone lines. This system used a network of DEC PDP11s. The software was written in Oregon Pascal with an event driven structure. This early involvement in event driven structures proved to be an invaluable stepping stone into Windows programming some years latter.

Doug completed a Graduate Diploma in Education at La Trobe University to become a qualified secondary school Mathematics and Physics teacher. Subsequent IT contracts were with universities. One such contract was to add functionality to MSN Messenger.

In recent times Doug has been working on database and Android applications.

Comments and Discussions