Click here to Skip to main content
15,917,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
Hi,

add a string member to your class 'CMemMapCppClientDlg'

in header file
class CMemMapCppClientDlg 
{ 
...

// add  your member
protected:
  CString m_strContent; 

// add access function to this member
public:
  CString GetContent();
};


in the source file
LRESULT CMemMapCppClientDlg::OnDataReady(WPARAM, LPARAM)
{
HANDLE hMapFile = NULL;
PVOID pView = NULL;

hMapFile = OpenFileMapping(FILE_MAP_READ, FALSE, m_pszMemMapFileName);
if(hMapFile == NULL) {
MessageBox("Can not open file mapping");
return 0;
}

pView = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
if(pView == NULL) {
MessageBox("Can map view of file");
CloseHandle(hMapFile);
return 0;
}

LPSTR szContent = reinterpret_cast(pView);
int nLen = strlen(szContent);
while(nLen > 0) {
m_strContent += *szContent++;
--nLen;
}
m_strContent += '\0';
m_strContent.Replace("\n", "\r\n");
// m_edit.SetWindowText(m_strContent);
MessageBox(m_strContent);

if(pView) UnmapViewOfFile(pView);
if(hMapFile) CloseHandle(hMapFile);

return 0;
}

// Implemtent new function
CString CMemMapCppClientDlg::GetContent()
{
  return m_strContent;
}


Now you can use the GetContent function to get the content

{
...
CMemMapCppClientDlg dlg;

...

CString strContent = dlg.GetContent();
...
}


codito ergo sum

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 
GeneralRe: Obtain a value from a variable in a class method. [modified] Pin
e40s8-Nov-07 9:05
e40s8-Nov-07 9:05 
Questionc++ path management functions Pin
Capitanevs7-Nov-07 10:15
Capitanevs7-Nov-07 10:15 
AnswerRe: c++ path management functions Pin
Mark Salsbery7-Nov-07 10:44
Mark Salsbery7-Nov-07 10:44 
GeneralRe: c++ path management functions Pin
Peter Weyzen7-Nov-07 15:33
Peter Weyzen7-Nov-07 15:33 
GeneralRe: c++ path management functions Pin
Roger Broomfield7-Nov-07 15:52
Roger Broomfield7-Nov-07 15:52 
QuestionHow can i open some Form application as child of other Form application ? Pin
Yanshof7-Nov-07 10:05
Yanshof7-Nov-07 10:05 
AnswerRe: How can i open some Form application as child of other Form application ? Pin
Hamid_RT7-Nov-07 17:36
Hamid_RT7-Nov-07 17:36 
GeneralRe: How can i open some Form application as child of other Form application ? Pin
Yanshof7-Nov-07 19:20
Yanshof7-Nov-07 19:20 
AnswerRe: How can i open some Form application as child of other Form application ? Pin
Nelek7-Nov-07 21:20
protectorNelek7-Nov-07 21:20 
GeneralRe: How can i open some Form application as child of other Form application ? Pin
Hamid_RT8-Nov-07 2:46
Hamid_RT8-Nov-07 2:46 
QuestionProject snapshot Pin
Larrson127-Nov-07 9:34
Larrson127-Nov-07 9:34 
AnswerRe: Project snapshot Pin
Maximilien7-Nov-07 9:52
Maximilien7-Nov-07 9:52 
AnswerRe: Project snapshot Pin
Peter Weyzen7-Nov-07 15:40
Peter Weyzen7-Nov-07 15:40 
QuestionURGENT : strange error C4430 VS2005 with ostream Pin
AhmedOsamaMoh7-Nov-07 8:08
AhmedOsamaMoh7-Nov-07 8:08 
AnswerRe: URGENT : strange error C4430 VS2005 with ostream Pin
Mark Salsbery7-Nov-07 8:18
Mark Salsbery7-Nov-07 8:18 

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.