Click here to Skip to main content
15,887,267 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: RTF file Pin
CPallini11-Dec-07 22:08
mveCPallini11-Dec-07 22:08 
GeneralRe: RTF file Pin
CodingLover11-Dec-07 22:20
CodingLover11-Dec-07 22:20 
GeneralRe: RTF file Pin
CPallini11-Dec-07 22:27
mveCPallini11-Dec-07 22:27 
GeneralRe: RTF file Pin
CodingLover11-Dec-07 22:37
CodingLover11-Dec-07 22:37 
Question<b>voice over ip between 2 hosts</b> [modified] Pin
Member 380822011-Dec-07 0:27
Member 380822011-Dec-07 0:27 
GeneralRe: voice over ip between 2 hosts Pin
Nelek11-Dec-07 1:29
protectorNelek11-Dec-07 1:29 
GeneralRe: voice over ip between 2 hosts Pin
JudyL_MD11-Dec-07 3:21
JudyL_MD11-Dec-07 3:21 
QuestionI need help in initialization list/constructor in abstraction Pin
taly11-Dec-07 0:23
taly11-Dec-07 0:23 
GeneralRe: I need help in initialization list/constructor in abstraction Pin
CPallini11-Dec-07 0:54
mveCPallini11-Dec-07 0:54 
QuestionRe: I need help in initialization list/constructor in abstraction Pin
taly11-Dec-07 1:20
taly11-Dec-07 1:20 
GeneralRe: I need help in initialization list/constructor in abstraction Pin
CPallini11-Dec-07 1:47
mveCPallini11-Dec-07 1:47 
QuestionHow to use more ocx in a dialog....... Pin
vineet p singh10-Dec-07 23:29
sussvineet p singh10-Dec-07 23:29 
GeneralRe: How to use more ocx in a dialog....... Pin
CPallini11-Dec-07 2:13
mveCPallini11-Dec-07 2:13 

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.