I have the following codes:

void CLOGFILE_INTERPRETERDlg::OnBtnLoad() 
{
	AfxGetModuleState()->m_dwVersion = 0x0601;			//corrects the differences in MS DAO
	UpdateData();
	m_Loading = _T("Loading...");
	UpdateData(FALSE);
	UpdateData(TRUE);
	//UpdateData();
	int length = 0;
	try {
		char strFilter[] = { "Log Files (*.log)|*.log|All Files (*.*)|*.*||" };

		CFileDialog FileDlg(TRUE, ".log", NULL, 0, strFilter);

		if ( FileDlg.DoModal() == IDOK) {
			CString szlstfile = FileDlg.GetPathName(); // This is your selected file name with path
			m_FileName = szlstfile;			AfxBeginThread(Parse,NULL,THREAD_PRIORITY_NORMAL,0,0,NULL);
		}
	} catch (long) {
		MessageBox("Log file cannot be loaded!!!","LOADING UNSUCCESSFUL",MB_OK|MB_ICONERROR);
	}
	m_Loading = _T("Done");
	UpdateData(FALSE);
	m_TreeView.EnableWindow(FALSE);
}

CString CLOGFILE_INTERPRETERDlg::Convert(CString temp) 
{
	AfxGetModuleState()->m_dwVersion = 0x0601;			//corrects the differences in MS DAO
	Code code;
	int group = 0;
	int startIndex = 0;
	int endIndex = 0;
	CString get;
	CString temp2;
	CString converted;
	CString translated = "";
	for ( int index = 0; index <= temp.GetLength(); index++ ) {
		if ( temp.Mid(index, 3) == "(0)" && group <= 0 ) {
			translated = translated + temp.Mid(index, 3);
			index = index + 2;
		} else if ( temp.Mid(index, 1) == "(" ) {
			group++;
			translated = translated + temp.Mid(index, 1);
			if ( temp.Mid(index + 1, 1) == "0" ) {
				startIndex = index + 1;
				endIndex = 0;
				for ( int index2 = index + 1; index2 <= temp.GetLength(); index2++ ) {
					if ( temp.Mid(index2, 1) == "(" || temp.Mid(index2, 1) == ")" ) {
						index2 = temp.GetLength();
					} else {
						endIndex++;
					}
				}
				converted = code.Convert(temp.Mid(startIndex, endIndex), get);
				translated = translated + converted;
				index = index + endIndex;
			}
		} else if ( temp.Mid(index, 1) == ")" ) {
			group--;
			translated = translated + temp.Mid(index, 1);
		} else if ( temp.Mid(index, 3) == "res" || temp.Mid(index, 3) == "req" ) {
			get = temp.Mid(index, 3);
			translated = translated + temp.Mid(index, 1);
		} else {
			translated = translated + temp.Mid(index, 1);
		}
	}
	return translated;
}

UINT CLOGFILE_INTERPRETERDlg::Parse( LPVOID Param ) {
	CStdioFile source;
	CStdioFile destination;
	source.Open(_T (m_FileName), CFile::modeReadWrite);
	destination.Open(_T ("C:/converted.txt"), CFile::modeReadWrite);
	char str[300];
	int range = 0;
	while(source.ReadString(str, 300)) {
		CString temp = "";
		CString translated = "";
		temp = temp + str;
		if ( temp.Find("(0.") > 0 ) {
			int pair = 0;
repeat:
			for ( int index = 0; index < temp.GetLength(); index++ ) {
				if ( temp.Mid(index, 1) == "(" ) {
					pair++;
				} else if ( temp.Mid(index, 1) == ")" ) {
					pair--;
				}
			}
			if ( pair != 0 ) {
				source.ReadString(str, 300);
				temp.TrimRight(" ");
				temp.TrimRight("\n");
				temp = temp + str;
				pair = 0;
				goto repeat;
			}
			//destination.Open(_T ("C:/converted.txt"), CFile::modeReadWrite);
			translated = Convert(temp);
		} else {
			translated = temp;
		}
		temp;
		destination.WriteString(translated);
	}
	destination.Close();
	source.Close();
	return true;
}

When I compile the program, I always got this error message:
C:\LOGFILE_INTERPRETER\LOGFILE_INTERPRETERDlg.cpp(355) : error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'
Error executing cl.exe.

Does anyone knows what is the problem with my codes?

When I compile the program, I always got this error message:
C:\LOGFILE_INTERPRETER\LOGFILE_INTERPRETERDlg.cpp(355) : error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'
Error executing cl.exe.

Does anyone knows what is the problem with my codes?

Which one of those line is line 355 in your *.cpp file? My guess is the compiler is complaining about the symbol Parse -- what is it (its supposed to be a function) If Parse is a function make sure it has the return type that AfxBeginThead() expects.

I would guess that it's complaining because Parse() is not declared static. If you can arrange for Parse() to be static, AfxBeginthread() will be a lot happier.

I would guess that it's complaining because Parse() is not declared static. If you can arrange for Parse() to be static, AfxBeginthread() will be a lot happier.

That might be correct if Phase() is a method of some class. Not necessary to be static if Phase() is just a simple global function.

That might be correct if Phase() is a method of some class. Not necessary to be static if Phase() is just a simple global function.

Parse() is defined on line 72 as a member of CLOGFILE_INTERPRETERDlg. The declaration is not shown however.

Parse() is defined on line 72 as a member of CLOGFILE_INTERPRETERDlg. The declaration is not shown however.

Oh yes -- you are correct.

Which one of those line is line 355 in your *.cpp file? My guess is the compiler is complaining about the symbol Parse -- what is it (its supposed to be a function) If Parse is a function make sure it has the return type that AfxBeginThead() expects.

Line 355 of the .cpp file:
AfxBeginThread(Parse,GetSafeHwnd(),THREAD_PRIORITY_NORMAL);

Parse() is defined on line 72 as a member of CLOGFILE_INTERPRETERDlg. The declaration is not shown however.

The declaration is in CLOGFILE_INTERPRETERDlg.h file. Below is the declaration on the header file:

UINT Parse(LPVOID Param);

The declaration is in CLOGFILE_INTERPRETERDlg.h file. Below is the declaration on the header file:

UINT Parse(LPVOID Param);

As it's in a class, it'll need to be a static function to work with AfxBeginThread(), so declare it:
static UINT Parse(LPVOID Param);

As Parse() calls Convert(), you will need to make Convert() static as well.

This article has been dead for over six months. Start a new discussion instead.