Click here to Skip to main content
15,896,154 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CRichEditView / CCTrlView text selection autocompletion Pin
Vaclav_11-Dec-07 6:10
Vaclav_11-Dec-07 6:10 
QuestionRelated to ocx Pin
Peter Parker11-Dec-07 2:31
Peter Parker11-Dec-07 2:31 
GeneralUhm... Pin
CPallini11-Dec-07 2:52
mveCPallini11-Dec-07 2:52 
JokeRe: Uhm... Pin
Cedric Moonen11-Dec-07 3:00
Cedric Moonen11-Dec-07 3:00 
GeneralRe: Uhm... Pin
toxcct11-Dec-07 3:02
toxcct11-Dec-07 3:02 
GeneralRe: Uhm... Pin
CPallini11-Dec-07 3:05
mveCPallini11-Dec-07 3:05 
GeneralRe: Uhm... Pin
toxcct11-Dec-07 3:03
toxcct11-Dec-07 3:03 
GeneralNope Pin
CPallini11-Dec-07 3:09
mveCPallini11-Dec-07 3:09 
QuestionWin32 SDK Save as Dialog Pin
sunsen11-Dec-07 2:03
sunsen11-Dec-07 2:03 
QuestionRe: Win32 SDK Save as Dialog Pin
David Crow14-Mar-08 5:57
David Crow14-Mar-08 5:57 
Generalserialization Pin
KASR111-Dec-07 1:09
KASR111-Dec-07 1:09 
GeneralRe: serialization Pin
Nelek11-Dec-07 1:33
protectorNelek11-Dec-07 1:33 
GeneralRe: serialization Pin
toxcct11-Dec-07 1:39
toxcct11-Dec-07 1:39 
QuestionToolbar in dialog caption. Pin
Paresh Chitte11-Dec-07 1:02
Paresh Chitte11-Dec-07 1:02 
GeneralRe: Toolbar in dialog caption. Pin
CPallini11-Dec-07 2:01
mveCPallini11-Dec-07 2:01 
GeneralInitilize value Pin
wira1guys11-Dec-07 0:38
wira1guys11-Dec-07 0:38 
GeneralRe: Initilize value Pin
Naveen11-Dec-07 0:59
Naveen11-Dec-07 0:59 
GeneralRe: Initilize value Pin
wira1guys11-Dec-07 16:59
wira1guys11-Dec-07 16:59 
GeneralRTF file Pin
CodingLover11-Dec-07 0:32
CodingLover11-Dec-07 0:32 
GeneralRe: RTF file Pin
CPallini11-Dec-07 0:57
mveCPallini11-Dec-07 0:57 
GeneralRe: RTF file Pin
CodingLover11-Dec-07 18:46
CodingLover11-Dec-07 18:46 
Ok, I have start work in this way. Read the file and get the content to a buffer. Then processing it until either '\' or '{' not find, so it should be a text word. Here is the code.

main function
<br />
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])<br />
{<br />
	int nRetCode = 0;<br />
<br />
	// initialize MFC and print and error on failure<br />
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))<br />
	{<br />
		// TODO: change error code to suit your needs<br />
		_tprintf(_T("Fatal Error: MFC initialization failed\n"));<br />
		nRetCode = 1;<br />
	}<br />
	else<br />
	{<br />
		// TODO: code your application's behavior here.<br />
		CFile rtfFile;// RTF file object<br />
		bool err = rtfFile.Open("G:\\Work On\\CPP\\Counter\\TestFile.rtf", CFile::modeReadWrite, NULL);<br />
<br />
		if(err != 0)<br />
		{<br />
			// Use the file size buffer<br />
			int length = rtfFile.GetLength();<br />
			char *pbuff = new char[length];<br />
<br />
			// Read the file to buffer<br />
			rtfFile.Read(pbuff, length);<br />
<br />
<br />
			CString text(getText(pbuff));<br />
<br />
			cout << (LPCTSTR)text;<br />
			<br />
			<br />
		}<br />
	}<br />
<br />
	return nRetCode;<br />
}<br />


getText function
<br />
CString getText(const CString & rtf)<br />
{<br />
	CString strCopy;// Hold the text<br />
	CString ch;// For next character<br />
	CString str(rtf.GetAt(1));<br />
	//CString str=rtf.GetAt(1);<br />
<br />
	BOOL bBrace = FALSE;// for '{'<br />
	BOOL bSlash = FALSE;// for '\'<br />
	BOOL bFirstLetter = FALSE;// first letter after the '\' sign<br />
<br />
	int nLength = rtf.GetLength();// Get the length again<br />
<br />
	// Just use as the dummy conditions. Length should be more that one<br />
	if (nLength < 4)<br />
	{<br />
		return "";<br />
	}<br />
<br />
	// Loop the length until find the EOF, using length of the RTF file<br />
	for (int i = 0; i < nLength; i++)<br />
	{<br />
		ch = rtf.GetAt(i);<br />
<br />
		if (ch.Find('\\') != -1)<br />
		{<br />
			bSlash = TRUE;<br />
			continue;<br />
		}<br />
		else if (ch.Find(' ') != -1)<br />
		{<br />
			bSlash = FALSE;<br />
			//Let it fall through so the space is added<br />
			//if we have found first letter<br />
			if (!bFirstLetter)<br />
			{<br />
				continue;<br />
			}<br />
		}<br />
		else if (ch.Find('{') != -1)<br />
		{<br />
			bBrace = TRUE;<br />
			bSlash = FALSE;<br />
			continue;<br />
		}<br />
		else if (ch.Find('}') != -1)<br />
		{<br />
			bSlash = FALSE;<br />
			bBrace = FALSE;<br />
			continue;<br />
		}<br />
<br />
		if (!bSlash && !bBrace)// check both '\' and '{' are avoided<br />
		{<br />
			if (!bFirstLetter)// set the first letter<br />
			{<br />
				bFirstLetter = TRUE;<br />
			}<br />
			strCopy += ch;<br />
			continue;<br />
		}<br />
	}<br />
	return strCopy;<br />
}<br />


My question is I can call the getText function inside the main function, gives an compilation error. Error is this,

unresolved external symbol "class ATL::CStringT<char,class strtraitmfc_dll<char,class="" atl::chtraitscrt<char=""> > > __cdecl getText(class ATL::CStringT<char,class strtraitmfc_dll<char,class="" atl::chtraitscrt<char=""> > >)" (?getText@@YA?AV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@V12@@Z) referenced in function _main</char,class></char,class>

Can you tell me where I'm going wrong.

I appreciate your help all the time...
Eranga Smile | :)

QuestionRe: RTF file Pin
CPallini11-Dec-07 21:34
mveCPallini11-Dec-07 21:34 
GeneralRe: RTF file Pin
CodingLover11-Dec-07 21:42
CodingLover11-Dec-07 21:42 
GeneralRe: RTF file Pin
CPallini11-Dec-07 21:53
mveCPallini11-Dec-07 21:53 
GeneralRe: RTF file Pin
CodingLover11-Dec-07 22:03
CodingLover11-Dec-07 22:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.