|
e40s wrote: So, one question is how do I use CMemMapCppClientDlg dlg;
elsewhere in the MemMapCppClient.cpp while still retaining the apps compilability?
Do the same thing that you have done earlier with the CString m_strContent by declaring the CMemMapCppClientDlg on the MemMapCppClient.h. Try if that works first.
e40s wrote: The bigger question is this: Even when all of this compiles perfectly, and my program works great--even the MessageBox gets displayed on cue--no content is there in the MessageBox. Never in any incarnation of a successful compile do I get content within the MessageBox. The prog always works perfectly otherwise.
Make it into this: MessageBox(strContent, _T("Like this:"));
By default the message box has an OK button so no need to add MB_OK there.
|
|
|
|
|
That suggestion works in some other parts of the program, but in this, MessageBoxA demands four arguments.
But there is something else I'm noticing: The strContent may never appear in the box because it's never arriving from GetContent().
In MemMapCppClientDlg, I added a MessageBox() to GetContent(), above the return, like so:
MessageBox(_T(m_strContent), _T("Forget this."));<br />
return m_strContent;
and got no content inside the MessageBox's client area. It's possible m_strContent isn't delivering a value.
Can someone please look at this--maybe specifically the header file, and see if something's lacking. A pointer maybe? I don't know; I'm lost.
Thanks again all.
|
|
|
|
|
It will be better if you use the < pre > < /pre > tags to englobe pieces of code, and the < code > < /code > to highlight little things. Is easier to read on the other way. And with pre the horizontal limit for a line is bigger, so commands won't be broken in different lines not so oft.
EDIT: Maybe a Site Admin could change the label from tags.
code -> Highlight (or something like that)
pre -> snippet (or something like that)
I had the same mistake at the beggining, I thought "paste code = code tag"
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Thanks for this, Nelek. I didn't know about pre.
|
|
|
|
|
Limit your use of the _T() macro to string literals, not variables.
e40s wrote: I get "initialization" errors.
This is too vague. What statement produces this?
e40s wrote: CString strContent = dlg.GetContent();
At this point has CMemMapCppClientDlg::OnDataReady() been called to add content to m_strContent ? If not, MessageBox() will obviously show nothing.
Why not use AfxMessageBox() instead? It won't solve your problem, but it takes much less code.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for replying David.
>> Limit your use of the _T() macro to string literals, not variables.
Thanks for the education. Will do.
>> This is too vague. What statement produces this?
My fault for bringing that initialization stuff up. I was straddling the statement in select case areas where I shouldn't have been. That problem's been solved, I believe, and pales in comparison to this:
>> At this point has CMemMapCppClientDlg::OnDataReady() been called to add content to m_strContent? If not, MessageBox() will obviously show nothing.
Yes. And that's the mystery.
But now I've confirmed, as I've written this morning, that even a MessageBox() statement inside of GetContent() fails to reveal the value of m_strContent. What's up with that?
(See, the thing is, if I take the comments off of the message box inside ::OnDataReady, the value appears just fine over there.)
Something missing from the header file? From the source? I wrote it up wrong from BK's script? I dunno.
>> Why not use AfxMessageBox() instead? It won't solve your problem, but it takes much less code.
Okay. I didn't know about that one.
-- modified at 11:18 Friday 9th November, 2007
|
|
|
|
|
e40s wrote: Yes. And that's the mystery.
But according to the code snippet you've shown, OnDataReady() has not been called prior to calling GetContent() . You are constructing a CMemMapCppClientDlg object and immediately calling GetContent() which will obviously return an empty string.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This is my observation.
My Excel file loads this DLL (the whole thing you're looking at in code). It's a DLL because I transmogrified the CodeProject sample from an .exe into one. Because it was originally authored as a Dlg, that window aspect of it remains. Anyway, when the Excel file loads this DLL, said Dialog immediately gets displayed on the screen (it's small and mostly blank, with a simple label in the center). Its job is to pass messages--because only a window can do that, evidently. When I'm finished with it, I destroy the window with a PostMessage().
Anyway, nothing happens display-wise--besides that dialog sitting there--until I fire up the Java side of this, which dispatches a message, via JNI, that is received by this DLL precisely at ::OnDataReady. Whatever content that JNI has passed immediately lands in m_strContent, and lights up the uncommented MessageBox.
To my knowledge, the Excel file way over at the other side does not touch OnDataReady. (Or I hope not. I don't want it to.) Excel is playing only at the CMemMapCppClientApp side--not the CMemMapCppClientDlg side.
Excel, and its loading of the DLL, never touch OnDataReady. (If they did, I would have seen the uncommented MessageBox inside OnDataReady light up immediately upon such an event. I never do.)
It is later, using Excel after Excel has already loaded the DLL prior, I only attempt to retrieve m_strContent value after JNI has already infilled it on the OnDataReady side. [The motivation for yesterday's and today's threads.] If I hear you right, you're suggesting that my invocation of the DLL at any time from Excel has an impact on OnDataReady. Because I never see any evidence of that--i.e., the uncommented MessageBox inside OnDataReady--I don't believe that suggested sequence of events to be the case.
I am calling CMemMapCppClientDlg::GetContent() exclusively from Excel by way of CMemMapCppClientApp. That action per se never, and shouldn't if I'm not mistaken (correct me if I'm wrong), in any way have an impact on OnDataReady. It can't.
-- modified at 12:25 Friday 9th November, 2007
|
|
|
|
|
All this extra stuff aside, the fact still remains that:
CMemMapCppClientDlg dlg;
CString strContent = dlg.GetContent();
MessageBox(NULL, strContent, _T("Like this:"), MB_OK); will do nothing but display an empty message box. You can verify this by initializing m_strContent to something in CMemMapCppClientDlg 's constructor.
After looking at what you've provided, it seems you have two instances of CMemMapCppClientDlg : the main one instantiated from CMemMapCppClientApp::InitInstance() , and another one instantiated from SumOneToArray() . Is that correct?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
>>After looking at what you've provided, it seems you have two instances of CMemMapCppClientDlg: the main one instantiated from CMemMapCppClientApp::InitInstance(), and another one instantiated from SumOneToArray(). Is that correct?
I don't believe so, but I can't say for certain. Can you tell me? Here's the full MemMapCppClient.cpp (ole2.h doesn't show up in our display here for the second #include because it's enclosed in less than/greater than punctuations):
#include "stdafx.h"
#include <ole2.h>
#include "MemMapCppClient.h"
#include "MemMapCppClientDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
VARIANT _stdcall CheckExcelArray(VARIANT& ExcelArray)
{
VARIANT dvout;
switch(ExcelArray.vt)
{
case VT_DISPATCH:
{
EXCEPINFO excep;
DISPPARAMS dispparams;
unsigned int uiArgErr;
DISPID dispidValue;
LPOLESTR XName = L"Value";
ExcelArray.pdispVal->GetIDsOfNames(IID_NULL, &XName,
1, LOCALE_SYSTEM_DEFAULT, &dispidValue);
dispparams.cArgs = 0;
dispparams.cNamedArgs = 0;
ExcelArray.pdispVal->Invoke(dispidValue, IID_NULL,
LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET,
&dispparams, &dvout, &excep, &uiArgErr);
ExcelArray.pdispVal->Release();
return dvout;
}
break;
default:
return ExcelArray;
break;
}
VariantClear(&dvout);
VariantClear(&ExcelArray);
}
VARIANT _stdcall SumOneToArray(VARIANT sourceArray)
{
CMemMapCppClientDlg dlg;
CString strContent = dlg.GetContent();
if(sourceArray.vt==VT_DISPATCH)
sourceArray = CheckExcelArray(sourceArray);
long ncols, nrows, i, j;
ncols=(sourceArray.parray)->rgsabound[0].cElements;
nrows=(sourceArray.parray)->rgsabound[1].cElements;
VARIANT *dArray = new VARIANT [nrows*ncols];
for(i=0; i<nrows; i++)
{
for(j=0; j<ncols; j++)
{
long indi[] = {i+1,j+1};
SafeArrayGetElement(sourceArray.parray, indi, &dArray[(i*ncols)+j]);
}
}
VARIANT destArray;
destArray.vt = VT_ARRAY | VT_VARIANT;
SAFEARRAYBOUND sab[2];
sab[0].lLbound = 1; sab[0].cElements = nrows;
sab[1].lLbound = 1; sab[1].cElements = ncols;
destArray.parray = SafeArrayCreate(VT_VARIANT, 2, sab);
for(i=0; i<nrows; i++)
{
for(j=0; j<ncols; j++)
{
long indi[] = {i+1,j+1};
switch(dArray[(i*ncols)+j].vt)
{
case VT_I2:
dArray[(i*ncols)+j].iVal=dArray[(i*ncols)+j].iVal + 1;
break;
case VT_R8:
dArray[(i*ncols)+j].dblVal=dArray[(i*ncols)+j].dblVal + 1;
break;
default:
break;
}
SafeArrayPutElement(destArray.parray, indi, &dArray[(i*ncols)+j]);
}
}
delete [] dArray;
return destArray;
VariantClear(&sourceArray);
VariantClear(&destArray);
}
BEGIN_MESSAGE_MAP(CMemMapCppClientApp, CWinApp)
END_MESSAGE_MAP()
CMemMapCppClientApp::CMemMapCppClientApp()
{
}
CMemMapCppClientApp theApp;
BOOL CMemMapCppClientApp::InitInstance()
{
CMemMapCppClientDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
return FALSE;
}
Here's the full MemMapCppClientDlg.cpp:
#include "stdafx.h"
#include "MemMapCppClient.h"
#include "MemMapCppClientDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
UINT CMemMapCppClientDlg::UWM_DATA_READY = RegisterWindowMessage(UWM_DATA_READY_MSG);
CMemMapCppClientDlg::CMemMapCppClientDlg(CWnd* pParent )
: CDialog(CMemMapCppClientDlg::IDD, pParent)
{
m_pszMemMapFileName = _T("Mem_Map_File-{70122C30-0239-4f98-9D21-36885C8A8121}");
}
BEGIN_MESSAGE_MAP(CMemMapCppClientDlg, CDialog)
ON_REGISTERED_MESSAGE(UWM_DATA_READY, OnDataReady)
END_MESSAGE_MAP()
BOOL CMemMapCppClientDlg::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE;
}
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<LPSTR>(pView);
int nLen = strlen(szContent);
CString m_strContent;
while(nLen > 0) {
m_strContent += *szContent++;
--nLen;
}
m_strContent += '\0';
m_strContent.Replace("\n", "\r\n");
MessageBox(m_strContent);
if(pView) UnmapViewOfFile(pView);
if(hMapFile) CloseHandle(hMapFile);
return 0;
}
CString CMemMapCppClientDlg::GetContent()
{
MessageBox(m_strContent, _T("Forget this."));
return m_strContent;
}
The full MemMapCppClient.h
#if !defined(AFX_MEMMAPCPPCLIENT_H__6FC73066_4FE5_46F4_891C_2434753F81AA__INCLUDED_)
#define AFX_MEMMAPCPPCLIENT_H__6FC73066_4FE5_46F4_891C_2434753F81AA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h"
class CMemMapCppClientApp : public CWinApp
{
public:
CMemMapCppClientApp();
public:
virtual BOOL InitInstance();
DECLARE_MESSAGE_MAP()
};
#endif // !defined(AFX_MEMMAPCPPCLIENT_H__6FC73066_4FE5_46F4_891C_2434753F81AA__INCLUDED_)
The full MemMapCppClientDlg.h:
#if !defined(AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_)
#define AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMemMapCppClientDlg : public CDialog
{
public:
static UINT UWM_DATA_READY;
CMemMapCppClientDlg(CWnd* pParent = NULL);
CString GetContent();
enum { IDD = IDD_MEMMAPCPPCLIENT_DIALOG };
protected:
protected:
virtual BOOL OnInitDialog();
afx_msg LRESULT OnDataReady(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
CString m_strContent;
private:
LPCTSTR m_pszMemMapFileName;
};
#define UWM_DATA_READY_MSG _T("UWM_DATA_READY_MSG-{7FDB2CB4-5510-4d30-99A9-CD7752E0D680}")
#endif // !defined(AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_)
-- modified at 12:41 Friday 9th November, 2007
|
|
|
|
|
e40s wrote: I don't believe so...
I do. Observe:
VARIANT _stdcall SumOneToArray(VARIANT sourceArray)
{
CMemMapCppClientDlg dlg;
CString strContent = dlg.GetContent();
...
}
BOOL CMemMapCppClientApp::InitInstance()
{
CMemMapCppClientDlg dlg;
m_pMainWnd = &dlg;
dlg.DoModal();
...
}
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Whoa! How'd you do that?
I'll pull it and see what happens.
|
|
|
|
|
So how do I get around this?
|
|
|
|
|
One way is to make the member variable static . This means that GetContent() will also need to be static .
Your next question (regarding scope) can be answered here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Okay, I changed it to this:
#if !defined(AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_)
#define AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMemMapCppClientDlg : public CDialog
{
public:
static UINT UWM_DATA_READY;
CMemMapCppClientDlg(CWnd* pParent = NULL);
static CString GetContent();
enum { IDD = IDD_MEMMAPCPPCLIENT_DIALOG };
protected:
protected:
virtual BOOL OnInitDialog();
afx_msg LRESULT OnDataReady(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
static CString m_strContent;
private:
LPCTSTR m_pszMemMapFileName;
};
#define UWM_DATA_READY_MSG _T("UWM_DATA_READY_MSG-{7FDB2CB4-5510-4d30-99A9-CD7752E0D680}")
#endif // !defined(AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_)
Fascinating. (I mean that sincerely.) Well, the first thing it did was change the argument disposition of MessageBox inside of GetContent(), so I commented that MessageBox line out there.
Attempted a recompile.
The errors:
1>MemMapCppClientDlg.obj : error LNK2001: unresolved external symbol "protected: static class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > CMemMapCppClientDlg::m_strContent" (?m_strContent@CMemMapCppClientDlg@@1V?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@A)
1>c:\experimental sample\Debug\MFC_DLL_03.dll : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\experimental sample\MFC_DLL_03\Debug\BuildLog.htm"
-- modified at 13:12 Friday 9th November, 2007
|
|
|
|
|
You have not initialized m_strContent . Static data members of classes must be initialized at file scope.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
The link was informative. (For the future, especially about their inability to access non-static class member data using the member-selection operators mentioned. Learning more every day.)
What I tried:
#if !defined(AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_)
#define AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMemMapCppClientDlg : public CDialog
{
public:
static UINT UWM_DATA_READY;
CMemMapCppClientDlg(CWnd* pParent = NULL);
static CString CMemMapCppClientDlg::GetContent();
enum { IDD = IDD_MEMMAPCPPCLIENT_DIALOG };
protected:
protected:
virtual BOOL OnInitDialog();
afx_msg LRESULT OnDataReady(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
static CString CMemMapCppClientDlg::m_strContent;
private:
LPCTSTR m_pszMemMapFileName;
};
#define UWM_DATA_READY_MSG _T("UWM_DATA_READY_MSG-{7FDB2CB4-5510-4d30-99A9-CD7752E0D680}")
#endif // !defined(AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_)
Darn. Same errors. (Afterward I even tried adding scope resolution to some of the statements on the .cpp. Nothing changed for the better so I took those off.)
|
|
|
|
|
e40s wrote: static CString CMemMapCppClientDlg::m_strContent;
Remove CMemMapCppClientDlg from the declaration. Add the following after CMemMapCppClientDlg 's constructor definition:
CString CMemMapCppClientDlg::m_strContent = "";
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I'm confused. There's a constructor in MemMapCppClientDlg.cpp. Do I involve the .cpp in the changes, or is just the MemMapCppClientDlg.h involved?
|
|
|
|
|
e40s wrote: Do I involve the .cpp in the changes...
Yes, since you have to do the initialization at file scope.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
It compiles, but I'm not getting anywhere. I'm so lost about following the instructions, I'm going to have to show the code. Here's the whole MemMapCppClientDlg.cpp:
#include "stdafx.h"
#include "MemMapCppClient.h"
#include "MemMapCppClientDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
UINT CMemMapCppClientDlg::UWM_DATA_READY = RegisterWindowMessage(UWM_DATA_READY_MSG);
CMemMapCppClientDlg::CMemMapCppClientDlg(CWnd* pParent )
: CDialog(CMemMapCppClientDlg::IDD, pParent)
{
m_pszMemMapFileName = _T("Mem_Map_File-{70122C30-0239-4f98-9D21-36885C8A8121}");
}
CString CMemMapCppClientDlg::m_strContent = "";
BEGIN_MESSAGE_MAP(CMemMapCppClientDlg, CDialog)
ON_REGISTERED_MESSAGE(UWM_DATA_READY, OnDataReady)
END_MESSAGE_MAP()
BOOL CMemMapCppClientDlg::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE;
}
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<LPSTR>(pView);
int nLen = strlen(szContent);
CString m_strContent;
while(nLen > 0) {
m_strContent += *szContent++;
--nLen;
}
m_strContent += '\0';
m_strContent.Replace("\n", "\r\n");
MessageBox(m_strContent);
if(pView) UnmapViewOfFile(pView);
if(hMapFile) CloseHandle(hMapFile);
return 0;
}
CString CMemMapCppClientDlg::GetContent()
{
return m_strContent;
}
Here's the MemMapCppClientDlg.h:
#if !defined(AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_)
#define AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMemMapCppClientDlg : public CDialog
{
public:
static UINT UWM_DATA_READY;
CMemMapCppClientDlg(CWnd* pParent = NULL);
static CString GetContent();
enum { IDD = IDD_MEMMAPCPPCLIENT_DIALOG };
protected:
protected:
virtual BOOL OnInitDialog();
afx_msg LRESULT OnDataReady(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
static CString m_strContent;
private:
LPCTSTR m_pszMemMapFileName;
};
#define UWM_DATA_READY_MSG _T("UWM_DATA_READY_MSG-{7FDB2CB4-5510-4d30-99A9-CD7752E0D680}")
#endif // !defined(AFX_MEMMAPCPPCLIENTDLG_H__A51F6AF7_F28D_461D_8FB3_EFC7B929D99C__INCLUDED_)
It compiles, but I followed the directions wrong. Nothing's showing up in the message box.
|
|
|
|
|
Knowing that a static asssignment can make this work is a lot further along than where I was yesterday (which is a lot farther than where I was the days and and weeks before that.)
I'm sorry I couldn't follow the instructions. My fault. I don't know if my changes to the code are right or wrong. But thanks for the guidance.
|
|
|
|
|
e40s wrote: Nothing's showing up in the message box.
It's probably because you are not modifying CMemMapCppClientDlg::m_strContent , but are modifying m_strContent that is local to OnDataReady() instead. Do you concur?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I don't understand. Are you saying you observe that's what I'm currently doing, and I shouldn't?
Or are you saying that's what I'm not currently doing?
Isn't m_strContect local to OnDataReady?
Where have I written something where I shouldn't? Where should I write something?
|
|
|
|
|
e40s wrote: Isn't m_strContect local to OnDataReady?
Yes, it has such a local variable that gets destroyed when OnDataReady() goes out of scope. Remove that one and you should be good to go.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|