Click here to Skip to main content
15,911,785 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: DLL_THREAD_ATTACH: Pin
ForNow8-Nov-07 23:16
ForNow8-Nov-07 23:16 
QuestionPerformance & Profiling... Pin
Peter Weyzen7-Nov-07 15:17
Peter Weyzen7-Nov-07 15:17 
AnswerRe: Performance & Profiling... Pin
Nelek7-Nov-07 21:31
protectorNelek7-Nov-07 21:31 
AnswerRe: Performance & Profiling... Pin
Blake Miller16-Nov-07 5:14
Blake Miller16-Nov-07 5:14 
QuestionSimple question about DLLS Pin
bigdenny2007-Nov-07 12:33
bigdenny2007-Nov-07 12:33 
AnswerRe: Simple question about DLLS Pin
Mark Salsbery7-Nov-07 13:27
Mark Salsbery7-Nov-07 13:27 
AnswerRe: Simple question about DLLS Pin
toxcct7-Nov-07 23:15
toxcct7-Nov-07 23:15 
QuestionObtain a value from a variable in a class method. Pin
e40s7-Nov-07 11:47
e40s7-Nov-07 11:47 
I don't know anythign about C++ or classes. All I know is there's a strContent variable sitting in this:
LRESULT CMemMapCppClientDlg::OnDataReady(WPARAM, LPARAM) <br />
{<br />
	HANDLE hMapFile = NULL;<br />
	PVOID pView = NULL;<br />
<br />
	hMapFile = OpenFileMapping(FILE_MAP_READ, FALSE, m_pszMemMapFileName);<br />
	if(hMapFile == NULL) {<br />
		MessageBox("Can not open file mapping");<br />
		return 0;<br />
	}<br />
<br />
	pView = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);<br />
	if(pView == NULL) {<br />
		MessageBox("Can map view of file");<br />
		CloseHandle(hMapFile);<br />
		return 0;<br />
	}<br />
<br />
	LPSTR szContent = reinterpret_cast<LPSTR>(pView);<br />
	int nLen = strlen(szContent);<br />
	CString strContent;<br />
	while(nLen > 0) {<br />
		strContent += *szContent++;<br />
		--nLen;<br />
	}<br />
	strContent += '\0';<br />
	strContent.Replace("\n", "\r\n");<br />
//	m_edit.SetWindowText(strContent);<br />
    MessageBox(strContent);<br />
<br />
	if(pView) UnmapViewOfFile(pView);<br />
	if(hMapFile) CloseHandle(hMapFile);<br />
<br />
	return 0;<br />
}
...which I need to get to from another area of the program.

(The snip is from a Memory Map sample app download from Code Project.)

Is there anybody that can show me how to make some kind of a call (from another class in another module) to this class to get at the value of strContent? Does strContent first need to somehow be teased out of ::onDataReady and placed in its own small function in order to make it available to be called from a separate part of the program.

Thank you if anyone can help.
QuestionRe: Obtain a value from a variable in a class method. Pin
David Crow7-Nov-07 16:56
David Crow7-Nov-07 16:56 
AnswerRe: Obtain a value from a variable in a class method. Pin
e40s8-Nov-07 3:21
e40s8-Nov-07 3:21 
GeneralRe: Obtain a value from a variable in a class method. Pin
toxcct8-Nov-07 3:28
toxcct8-Nov-07 3:28 
JokeRe: Obtain a value from a variable in a class method. Pin
David Crow8-Nov-07 3:30
David Crow8-Nov-07 3:30 
GeneralRe: Obtain a value from a variable in a class method. Pin
toxcct8-Nov-07 3:33
toxcct8-Nov-07 3:33 
GeneralRe: Obtain a value from a variable in a class method. [modified] Pin
e40s8-Nov-07 3:52
e40s8-Nov-07 3:52 
GeneralRe: Obtain a value from a variable in a class method. Pin
toxcct8-Nov-07 5:12
toxcct8-Nov-07 5:12 
GeneralRe: Obtain a value from a variable in a class method. Pin
e40s8-Nov-07 5:36
e40s8-Nov-07 5:36 
GeneralRe: Obtain a value from a variable in a class method. Pin
toxcct8-Nov-07 5:54
toxcct8-Nov-07 5:54 
GeneralRe: Obtain a value from a variable in a class method. [modified] Pin
e40s8-Nov-07 5:58
e40s8-Nov-07 5:58 
GeneralRe: Obtain a value from a variable in a class method. Pin
toxcct8-Nov-07 6:23
toxcct8-Nov-07 6:23 
GeneralRe: Obtain a value from a variable in a class method. Pin
e40s8-Nov-07 6:37
e40s8-Nov-07 6:37 
GeneralRe: Obtain a value from a variable in a class method. Pin
toxcct8-Nov-07 6:45
toxcct8-Nov-07 6:45 
GeneralRe: Obtain a value from a variable in a class method. Pin
e40s8-Nov-07 7:00
e40s8-Nov-07 7:00 
GeneralRe: Obtain a value from a variable in a class method. Pin
BadKarma8-Nov-07 5:13
BadKarma8-Nov-07 5:13 
GeneralRe: Obtain a value from a variable in a class method. Pin
e40s8-Nov-07 5:26
e40s8-Nov-07 5:26 
GeneralRe: Obtain a value from a variable in a class method. Pin
David Crow8-Nov-07 8:43
David Crow8-Nov-07 8:43 

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.