-
error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,StringTrai
Hi, im trying to update the value of an edit box in a modeless dialog box, but I keep getting the following error message:
error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,StringTraits>'
Here is the code:
void MySdk2Client::SdkDataHasArrived(sFrameOfData* data)
{
WriteFrame(data);
// Stop accepting frames of data once we reach the number set by the user
if (++m_frameCount == m_maxFrames)
{
m_acceptData = false;
}
if (m_frameCount % 10 == 0)
{
CString m_NOFR;
m_NOFR.SetWindowText("%d\r", m_frameCount);
}
}
Here is code from the dialog box:
void CConnectDlg::OnBnClickedOk()
{
CString m_Eipaddress;
GetDlgItem( IDC_EDT_EIPADDRESS )->GetWindowText( m_Eipaddress);
CString m_Cipaddress;
GetDlgItem( IDC_EDT_CIPADDRESS )->GetWindowText( m_Cipaddress);
CString m_NOFTR;
GetDlgItem( IDC_EDT_NOFTR )->GetWindowText( m_NOFTR);
{
MySdk2Client sdkClient;
// Try to connect to the given server
if (sdkClient.Connect(m_Eipaddress, m_Cipaddress,atoi(m_NOFTR)))
{
m_Status.SetWindowText("Connected");
// Just wait until we've received the required number of frames
while (sdkClient.IsFinished() == false)
{
Sleep(1000);
}
sdkClient.Disconnect();
m_Status.SetWindowText("Finished Recording Frames");
}
else
{
m_Status.SetWindowText("Could not connect to System");
}
}
}
What i don't understand is, im using setwindowtext for m_status and it works fine.
Any help will be greatly appreciated.
thanks
steph
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
m_NOFR is a string, not a window. I can't see what m_Status is, but I assume it is a editbox or a label or something like that.
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
Skizmo
m_NOFR is a string, not a window. I can't see what m_Status is, but I assume it is a editbox or a label or something like that.
m_NOFR is an edit box and m_status is static text, I want to use the value behind m_frameCount to show up in the edit box m_NOFR.
Thanks
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Then again, looking at these lines of code:
Code:
CString m_NOFR;
m_NOFR.SetWindowText("%d\r", m_frameCount);
m_NOFR is not a window but a CString, at least in this context.
You may want to look if you have this variable has the same name as a member of the class...
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
Elrond
Then again, looking at these lines of code:
Code:
CString m_NOFR;
m_NOFR.SetWindowText("%d\r", m_frameCount);
m_NOFR
is not a window but a CString, at least in this context.
You may want to look if you have this variable has the same name as a member of the class...
I have taken out the ctring and left it like this:
m_NOFR.SetWindowText("%d\r", m_frameCount);
now i get 2 errors:
error C2065: 'm_NOFR' : undeclared identifier
error C2228: left of '.SetWindowTextA' must have class/struct/union
m_NOFR is in public so why can it not see it?
and i don't know what the c2228 error is?
thanks
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
1. We can't see anywhere in the code sample you provide where m_NOFR is coming from. There is part of your code missing (definition of the dialog class from the .h file for a start).
2. The parameters ("%d\r", m_frameCount) seem more appropriate as parameters for the "Format" method of CString than as parameters of SetWindowText of CWnd.
3. About your 2 errors, the first simply indicate that m_NOFR is nowhere in the scope of where you are using it. The second is related to the first, simply indicating that ".SetWindowTextA" should have something valid that can refer to such a method on the left.
Putting m_NOFR as a public member of a class does not mean it can be used freely anywhere. It is still a member of the class and has to be used as such, something like:
Code:
CMyDlg dlg;
dlg.m_NOFR = "some string";
Unless you use it in the methods associated with the class itself.
But in your code sample, you use it in a method from CConnectDlg (which it is probably member of) and in a method of the class MySdk2Client. The second is definitely not correct.
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
Elrond
1. We can't see anywhere in the code sample you provide where m_NOFR is coming from. There is part of your code missing (definition of the dialog class from the .h file for a start).
2. The parameters ("%d\r", m_frameCount) seem more appropriate as parameters for the "Format" method of CString than as parameters of SetWindowText of CWnd.
3. About your 2 errors, the first simply indicate that m_NOFR is nowhere in the scope of where you are using it. The second is related to the first, simply indicating that ".SetWindowTextA" should have something valid that can refer to such a method on the left.
Putting m_NOFR as a public member of a class does not mean it can be used freely anywhere. It is still a member of the class and has to be used as such, something like:
Code:
CMyDlg dlg;
dlg.m_NOFR = "some string";
Unless you use it in the methods associated with the class itself.
But in your code sample, you use it in a method from CConnectDlg (which it is probably member of) and in a method of the class MySdk2Client. The second is definitely not correct.
Hi, sorry if I was unclear in my original post, I am fairly new to programming, and this is my very first application I am trying to create, thank you for your patience and understanding. I decided to post the complete header and cpp file for the dialog box, for your reference:
ConnectDlg.h:
Code:
#pragma once
#include "afxwin.h"
// CConnectDlg dialog
class CConnectDlg : public CDialog
{
DECLARE_DYNAMIC(CConnectDlg)
public:
CConnectDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CConnectDlg();
// Dialog Data
enum { IDD = IDD_CONNECT };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CString m_NOFTR;
CString m_NOFR;
DWORD m_Eipaddress;
DWORD m_Cipaddress;
afx_msg void OnBnClickedOk();
CStatic m_Status;
};
ConnectDlg.cpp:
// ConnectDlg.cpp : implementation file
#include "stdafx.h"
#include "Viewer.h"
#include "ConnectDlg.h"
#include <windows.h>
#include "EvartSdk2Interface.h"
// CConnectDlg dialog
IMPLEMENT_DYNAMIC(CConnectDlg, CDialog)
CConnectDlg::CConnectDlg(CWnd* pParent /*=NULL*/)
: CDialog(CConnectDlg::IDD, pParent)
, m_NOFTR(_T(""))
, m_NOFR(_T(""))
, m_Eipaddress(0)
, m_Cipaddress(0)
{
}
CConnectDlg::~CConnectDlg()
{
}
void CConnectDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDT_NOFTR, m_NOFTR);
DDX_Text(pDX, IDC_EDT_NOFR, m_NOFR);
DDX_IPAddress(pDX, IDC_EDT_EIPADDRESS, m_Eipaddress);
DDX_IPAddress(pDX, IDC_EDT_CIPADDRESS, m_Cipaddress);
DDX_Control(pDX, IDC_NOT_STATUS, m_Status);
}
BEGIN_MESSAGE_MAP(CConnectDlg, CDialog)
ON_BN_CLICKED(IDOK, &CConnectDlg::OnBnClickedOk)
END_MESSAGE_MAP()
typedef enum
{
IDENTIFIED_MKRS = 0,
UNIDENTIFIED_MKRS,
SEGMENT_DATA,
DOF_DATA,
ANALOG_DATA,
FORCE_DATA,
DATA_TYPE_COUNT
} kDataTypes;
// Change these to zero if you don't want a file written for a particular data type
#define WRITE_IDENTIFIED_MKRS 1
#define WRITE_UNIDENTIFIED_MKRS 0
#define WRITE_SEGMENT_DATA 0
#define WRITE_DOF_DATA 0
#define WRITE_ANALOG_DATA 0
#define WRITE_FORCE_DATA 0
class MySdk2Client : public ISdkDataListener
{
public:
// Constructor
MySdk2Client() : m_acceptData(false)
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
m_dataFiles[i] = NULL;
}
}
// Destructor, must close the data files
~MySdk2Client()
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
if (m_dataFiles[i]) fclose(m_dataFiles[i]);
}
}
.
virtual void SdkDataHasArrived(sFrameOfData* data);
virtual bool AcceptingSdkData() const { return m_acceptData; }
bool Connect(const char* serverIP, const char* clientIP, int maxFrames);
bool IsFinished() const { return m_frameCount >= m_maxFrames; }
void Disconnect()
{
m_sdk.SetDataListener(NULL);
m_sdk.Uninitialize();
}
// Create a file for the given data type
bool CreateDataFile(int dataType, const char* filename)
{
bool rc = false;
if (dataType >= 0 && dataType < DATA_TYPE_COUNT)
{
m_dataFiles[dataType] = fopen(filename, "w");
rc = (m_dataFiles[dataType] != NULL);
}
return rc;
}
private:
bool m_acceptData;
int m_frameCount;
int m_maxFrames;
FILE* m_dataFiles[DATA_TYPE_COUNT];
EvartSdk2Interface m_sdk;
void WriteFileHeader(int dataType, sBodyDefs* bodyDefs);
void WriteFrame(sFrameOfData* data);
void WriteIdentifiedHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteUnidentifiedHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteSegmentHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteDofHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteAnalogHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteForceHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteIdentifiedFrame(FILE* fp, sFrameOfData* data);
void WriteUnidentifiedFrame(FILE* fp, sFrameOfData* data);
void WriteSegmentFrame(FILE* fp, sFrameOfData* data);
void WriteDofFrame(FILE* fp, sFrameOfData* data);
void WriteAnalogFrame(FILE* fp, sFrameOfData* data);
void WriteForceFrame(FILE* fp, sFrameOfData* data);
};
// CConnectDlg message handlers
void CConnectDlg::OnBnClickedOk()
{
CString m_Eipaddress;
GetDlgItem( IDC_EDT_EIPADDRESS )->GetWindowText( m_Eipaddress);
CString m_Cipaddress;
GetDlgItem( IDC_EDT_CIPADDRESS )->GetWindowText( m_Cipaddress);
CString m_NOFTR;
GetDlgItem( IDC_EDT_NOFTR )->GetWindowText( m_NOFTR);
{
MySdk2Client sdkClient;
// Try to connect to the given SDK2 server
if (sdkClient.Connect(m_Eipaddress, m_Cipaddress,atoi(m_NOFTR)))
{
m_Status.SetWindowText("Connected");
// Just wait until we've received the required number of frames
while (sdkClient.IsFinished() == false)
{
Sleep(1000);
}
sdkClient.Disconnect();
}
else
{
m_Status.SetWindowText("Could not connect to EVaRT System");
}
}
}
void MySdk2Client::SdkDataHasArrived(sFrameOfData* data)
{
WriteFrame(data);
// Stop accepting frames of data once we reach the number set by the user on the command line
if (++m_frameCount == m_maxFrames)
{
m_acceptData = false;
}
if (m_frameCount % 10 == 0)
{
m_NOFR.SetWindowText("%d\r", m_frameCount);
}
}
bool MySdk2Client::Connect(const char* serverIP, const char* clientIP, int maxFrames)
{
bool rc;
sBodyDefs* evartObjects = NULL;
m_maxFrames = maxFrames;
m_frameCount = 0;
// Initialize the EVaRT SDK2
rc = m_sdk.Initialize(clientIP, serverIP);
// Query the list of objects that EVaRT is currently tracking
evartObjects = m_sdk.GetBodyDefinitions();
if (rc && evartObjects)
{
#if WRITE_IDENTIFIED_MKRS
if (CreateDataFile(IDENTIFIED_MKRS, "named_mkrs.csv"))
{
WriteFileHeader(IDENTIFIED_MKRS, evartObjects);
}
#endif
#if WRITE_UNIDENTIFIED_MKRS
if (CreateDataFile(UNIDENTIFIED_MKRS, "unnamed_mkrs.csv"))
{
WriteFileHeader(UNIDENTIFIED_MKRS, evartObjects);
}
#endif
#if WRITE_SEGMENT_DATA
if (CreateDataFile(SEGMENT_DATA, "segment_data.csv"))
{
WriteFileHeader(SEGMENT_DATA, evartObjects);
}
#endif
#if WRITE_DOF_DATA
if (CreateDataFile(DOF_DATA, "dof_data.csv"))
{
WriteFileHeader(DOF_DATA, evartObjects);
}
#endif
#if WRITE_ANALOG_DATA
if (CreateDataFile(ANALOG_DATA, "analog_data.csv"))
{
WriteFileHeader(ANALOG_DATA, evartObjects);
}
#endif
#if WRITE_FORCE_DATA
if (CreateDataFile(FORCE_DATA, "force_data.csv"))
{
WriteFileHeader(FORCE_DATA, evartObjects);
}
#endif
// Register ourselves as a listener
m_sdk.SetDataListener(this);
// We are now ready to accept frames of data from EVaRT
m_acceptData = true;
}
else
{
rc = false;
}
// Free memory for the EVaRT body definitions
m_sdk.FreeBodyDefinitions(evartObjects);
return rc;
}
// Write out a file header for the given data type
void MySdk2Client::WriteFileHeader(int dataType, sBodyDefs* bodyDefs)
{
if (dataType < 0) return;
if (dataType >= DATA_TYPE_COUNT) return;
if (m_dataFiles[dataType] == NULL) return;
FILE* fp = m_dataFiles[dataType];
switch (dataType)
{
case IDENTIFIED_MKRS:
WriteIdentifiedHeader(fp, bodyDefs);
break;
case UNIDENTIFIED_MKRS:
WriteUnidentifiedHeader(fp, bodyDefs);
break;
case SEGMENT_DATA:
WriteSegmentHeader(fp, bodyDefs);
break;
case DOF_DATA:
WriteDofHeader(fp, bodyDefs);
break;
case ANALOG_DATA:
WriteAnalogHeader(fp, bodyDefs);
break;
case FORCE_DATA:
WriteForceHeader(fp, bodyDefs);
break;
default:
break;
}
}
void MySdk2Client::WriteFrame(sFrameOfData* data)
{
if (m_dataFiles[IDENTIFIED_MKRS])
{
WriteIdentifiedFrame(m_dataFiles[IDENTIFIED_MKRS], data);
}
if (m_dataFiles[UNIDENTIFIED_MKRS])
{
WriteUnidentifiedFrame(m_dataFiles[UNIDENTIFIED_MKRS], data);
}
if (m_dataFiles[SEGMENT_DATA])
{
WriteSegmentFrame(m_dataFiles[SEGMENT_DATA], data);
}
if (m_dataFiles[DOF_DATA])
{
WriteDofFrame(m_dataFiles[DOF_DATA], data);
}
if (m_dataFiles[ANALOG_DATA])
{
WriteAnalogFrame(m_dataFiles[ANALOG_DATA], data);
}
if (m_dataFiles[FORCE_DATA])
{
WriteForceFrame(m_dataFiles[FORCE_DATA], data);
}
}
void MySdk2Client::WriteIdentifiedHeader(FILE* fp, sBodyDefs* bodyDefs)
{
int i, j;
fprintf(fp, "Markers:");
// Write out all of the marker names
for (i = 0; i < bodyDefs->nBodyDefs; i++)
{
for (j = 0; j < bodyDefs->BodyDefs[i].nMarkers; j++)
{
fprintf(fp, ",%s,,", bodyDefs->BodyDefs[i].szMarkerNames[j]);
}
}
fprintf(fp, "\nFrame#");
// Make columns for X, Y, Z for each marker
for (i = 0; i < bodyDefs->nBodyDefs; i++)
{
for (j = 0; j < bodyDefs->BodyDefs[i].nMarkers; j++)
{
char* name = bodyDefs->BodyDefs[i].szMarkerNames[j];
fprintf(fp, ",%s_X,%s_Y,%s_Z", name, name, name);
}
}
fprintf(fp, "\n");
}
void MySdk2Client::WriteUnidentifiedHeader(FILE* fp, sBodyDefs* bodyDefs)
{
const int MAX_UNNAMED = 50;
const char* name = "Unnamed";
int i;
fprintf(fp, "Markers:");
// Make room for MAX_UNNAMED marker slots
for (i = 0; i < MAX_UNNAMED; i++)
{
fprintf(fp, ",%s%d,,", name, i);
}
fprintf(fp, "\nFrame#");
// Make columns for X, Y, Z for each marker
for (i = 0; i < MAX_UNNAMED; i++)
{
fprintf(fp, ",%s%d_X,%s%d_Y,%s%d_Z", name, i, name, i, name, i);
}
fprintf(fp, "\n");
}
void MySdk2Client::WriteSegmentHeader(FILE* fp, sBodyDefs* bodyDefs)
{
int i, j;
// Write out the segment hierarchy
fprintf(fp, "CHILD,PARENT\n");
for (i = 0; i < bodyDefs->nBodyDefs; i++)
{
for (j = 0; j < bodyDefs->BodyDefs[i].Hierarchy.nSegments; j++)
{
char* child = bodyDefs->BodyDefs[i].Hierarchy.szSegmentNames[j];
int parentIndex = bodyDefs->BodyDefs[i].Hierarchy.iParents[j];
char* parent = parentIndex >= 0 ? bodyDefs->BodyDefs[i].Hierarchy.szSegmentNames[parentIndex] : "GLOBAL";
fprintf(fp, "%s,%s\n", child, parent);
}
}
fprintf(fp, "\n\n");
fprintf(fp, "Segments:");
// Write out all of the segment names
for (i = 0; i < bodyDefs->nBodyDefs; i++)
{
for (j = 0; j < bodyDefs->BodyDefs[i].Hierarchy.nSegments; j++)
{
fprintf(fp, ",%s,,,,,,", bodyDefs->BodyDefs[i].Hierarchy.szSegmentNames[j]);
}
}
fprintf(fp, "\nFrame#");
// Make columns for TX, TY, TZ, RX, RY, RZ, Length
for (i = 0; i < bodyDefs->nBodyDefs; i++)
{
for (j = 0; j < bodyDefs->BodyDefs[i].Hierarchy.nSegments; j++)
{
char* name = bodyDefs->BodyDefs[i].Hierarchy.szSegmentNames[j];
fprintf(fp, ",%s_TX,%s_TY,%s_TZ,%s_RX,%s_RY,%s_RZ,%s_Len", name, name, name, name, name, name, name);
}
}
fprintf(fp, "\n");
}
void MySdk2Client::WriteDofHeader(FILE* fp, sBodyDefs* bodyDefs)
{
int i, j;
fprintf(fp, "Frame#");
// Write out all of the DOF names
for (i = 0; i < bodyDefs->nBodyDefs; i++)
{
for (j = 0; j < bodyDefs->BodyDefs[i].nDofs; j++)
{
fprintf(fp, ",%s", bodyDefs->BodyDefs[i].szDofNames[j]);
}
}
fprintf(fp, "\n");
}
void MySdk2Client::WriteAnalogHeader(FILE* fp, sBodyDefs* bodyDefs)
{
int i;
fprintf(fp, "Frame#,Sample#");
// Write out all of the analog channel names
for (i = 0; i < bodyDefs->nAnalogChannels; i++)
{
fprintf(fp, ",%s", bodyDefs->szAnalogChannelNames[i]);
}
fprintf(fp, "\n");
}
void MySdk2Client::WriteForceHeader(FILE* fp, sBodyDefs* bodyDefs)
{
const char* names[] = {"X", "Y", "Z", "fX", "fY", "fZ", "mZ"};
int i;
fprintf(fp, "Frame#,Sample#");
// Write out all of the force plate channel names
for (i = 0; i < bodyDefs->nForcePlates; i++)
{
for (int j = 0; j < 7; j++)
{
fprintf(fp, ",FP%d_%s", i+1, names[j]);
}
}
fprintf(fp, "\n");
}
void MySdk2Client::WriteIdentifiedFrame(FILE* fp, sFrameOfData* data)
{
// Write out frame number
fprintf(fp, "%d", data->iFrame);
// Write out X, Y, Z for each marker
for (int i = 0; i < data->nBodies; i++)
{
for (int j = 0; j < data->BodyData[i].nMarkers; j++)
{
if (data->BodyData[i].Markers[j][0] < XEMPTY)
{
fprintf(fp, ",%f,%f,%f",
data->BodyData[i].Markers[j][0],
data->BodyData[i].Markers[j][1],
data->BodyData[i].Markers[j][2]);
}
else
{
fprintf(fp, ",%f,%f,%f",
0.0,
0.0,
0.0);
}
}
}
fprintf(fp, "\n");
}
void MySdk2Client::WriteUnidentifiedFrame(FILE* fp, sFrameOfData* data)
{
// Write out frame number
fprintf(fp, "%d", data->iFrame);
// Write out X, Y, Z for each unnamed marker
for (int i = 0; i < data->nUnidentifiedMarkers; i++)
{
fprintf(fp, ",%f,%f,%f",
data->UnidentifiedMarkers[i][0],
data->UnidentifiedMarkers[i][1],
data->UnidentifiedMarkers[i][2]);
}
fprintf(fp, "\n");
}
void MySdk2Client::WriteSegmentFrame(FILE* fp, sFrameOfData* data)
{
// Write out frame number
fprintf(fp, "%d", data->iFrame);
// Write out TX, TY, TZ, RX, RY, RZ, Length for each segment
for (int i = 0; i < data->nBodies; i++)
{
for (int j = 0; j < data->BodyData[i].nSegments; j++)
{
if (data->BodyData[i].Segments[j][0] < XEMPTY)
{
fprintf(fp, ",%f,%f,%f,%f,%f,%f,%f",
data->BodyData[i].Segments[j][0],
data->BodyData[i].Segments[j][1],
data->BodyData[i].Segments[j][2],
data->BodyData[i].Segments[j][3],
data->BodyData[i].Segments[j][4],
data->BodyData[i].Segments[j][5],
data->BodyData[i].Segments[j][6]);
}
else
{
fprintf(fp, ",%f,%f,%f,%f,%f,%f,%f",
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0);
}
}
}
fprintf(fp, "\n");
}
void MySdk2Client::WriteDofFrame(FILE* fp, sFrameOfData* data)
{
// Write out frame number
fprintf(fp, "%d", data->iFrame);
// Write out value for each dof
for (int i = 0; i < data->nBodies; i++)
{
for (int j = 0; j < data->BodyData[i].nDofs; j++)
{
if (data->BodyData[i].Dofs[j] < XEMPTY)
{
fprintf(fp, ",%f", data->BodyData[i].Dofs[j]);
}
else
{
fprintf(fp, ",%f", 0.0);
}
}
}
fprintf(fp, "\n");
}
void MySdk2Client::WriteAnalogFrame(FILE* fp, sFrameOfData* data)
{
static int sample = 0;
int nChannels = data->AnalogData.nAnalogChannels;
int nSamples = data->AnalogData.nAnalogSamples;
// Write out frame number
fprintf(fp, "%d", data->iFrame);
for (int i = 0; i < nSamples; i++)
{
// Write out sample number
fprintf(fp, ",%d", sample++);
// Write out data for each channel
for (int j = 0; j < nChannels; j++)
{
fprintf(fp, ",%hd", data->AnalogData.AnalogSamples[i*nChannels + j]);
}
if (i != nSamples - 1) fprintf(fp, "\n");
}
fprintf(fp, "\n");
}
void MySdk2Client::WriteForceFrame(FILE* fp, sFrameOfData* data)
{
static int sample = 0;
int nPlates = data->AnalogData.nForcePlates;
int nSamples = data->AnalogData.nForceSamples;
// Write out frame number
fprintf(fp, "%d", data->iFrame);
for (int i = 0; i < nSamples; i++)
{
// Write out sample number
fprintf(fp, ",%d", sample++);
// Write out data for each plate
for (int j = 0; j < nPlates; j++)
{
fprintf(fp, ",%f,%f,%f,%f,%f,%f,%f",
data->AnalogData.Forces[i*nPlates + j][0],
data->AnalogData.Forces[i*nPlates + j][1],
data->AnalogData.Forces[i*nPlates + j][2],
data->AnalogData.Forces[i*nPlates + j][3],
data->AnalogData.Forces[i*nPlates + j][4],
data->AnalogData.Forces[i*nPlates + j][5],
data->AnalogData.Forces[i*nPlates + j][6]);
}
if (i != nSamples - 1) fprintf(fp, "\n");
}
fprintf(fp, "\n");
}
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
First, using the "code" tags would make it easier to read your code. Any way:
Code:
class CConnectDlg : public CDialog
{
...
public:
CString m_NOFR;
...
};
This shows that m_NOFR is a CString. It is associated to an edit box, but it is a CString.
To update the content of the window after updating the CString you need to do:
Code:
m_NOFR = "some string";
UpdateData(FALSE);
To update the CString with text that has been written in the edit box by the user you need to do:
Just using the second in your method OnBnClickedOk() is enough.
Your other problem is that you class MySdkClient does not know about you dialog, so it cannot update the dialog data the way you are trying to do. You need to give to this class a pointer to the dialog, and then probably a method to update the data you want, probably one method per edit box, in which you will find code similar to my first sample.
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Hi Elrond, thanks for your reply, It looks like we have our wires crossed somwhere, or more likely i'm just really bad explaining myself. sorry,
I will explain from the beginning again.
I have my application which displays 3d graphics, there is a modeless dialog box within this program that is used to connect to a 3rd party program and write information to a file. I have successfully got the diaolog box to connect to the 3rd party program with the user having to enter the client ip address, the system ip address and the amount of frames to record. What I am having problems with is letting the user know how many frames are being captured in real-time.
This time I will try and use the "code" tags as you mentioned and only put the necessary code to explain what I am trying to achieve.
Every time each frame is written it runs this:
void MySdk2Client::SdkDataHasArrived(sFrameOfData* data)
At which point I want to update the edit box m_NOFR with the frame number in other words with m_frameCount.
I have put this "*****This is where i need to put the code to update the m_NOFR edit box******" where i think the code needs to go.
I hope this is a little clearer, thanks again for all your help and assistance, I really appreciate it.
Regards
Steph
CConnectDlg.h
Code:
#pragma once
#include "afxwin.h"
// CConnectDlg dialog
class CConnectDlg : public CDialog
{
DECLARE_DYNAMIC(CConnectDlg)
public:
CConnectDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CConnectDlg();
// Dialog Data
enum { IDD = IDD_CONNECT };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CString m_NOFTR;
CString m_NOFR;
DWORD m_Eipaddress;
DWORD m_Cipaddress;
afx_msg void OnBnClickedOk();
CStatic m_Status;
};
CConnectDlg.cpp
Code:
// ConnectDlg.cpp : implementation file
#include "stdafx.h"
#include "Viewer.h"
#include "ConnectDlg.h"
#include <windows.h>
#include "EvartSdk2Interface.h"
// CConnectDlg dialog
IMPLEMENT_DYNAMIC(CConnectDlg, CDialog)
CConnectDlg::CConnectDlg(CWnd* pParent /*=NULL*/)
: CDialog(CConnectDlg::IDD, pParent)
, m_NOFTR(_T(""))
, m_NOFR(_T(""))
, m_Eipaddress(0)
, m_Cipaddress(0)
{
}
CConnectDlg::~CConnectDlg()
{
}
void CConnectDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDT_NOFTR, m_NOFTR);
DDX_Text(pDX, IDC_EDT_NOFR, m_NOFR);
DDX_IPAddress(pDX, IDC_EDT_EIPADDRESS, m_Eipaddress);
DDX_IPAddress(pDX, IDC_EDT_CIPADDRESS, m_Cipaddress);
DDX_Control(pDX, IDC_NOT_STATUS, m_Status);
}
BEGIN_MESSAGE_MAP(CConnectDlg, CDialog)
ON_BN_CLICKED(IDOK, &CConnectDlg::OnBnClickedOk)
END_MESSAGE_MAP()
typedef enum
{
IDENTIFIED_MKRS = 0,
UNIDENTIFIED_MKRS,
SEGMENT_DATA,
DOF_DATA,
ANALOG_DATA,
FORCE_DATA,
DATA_TYPE_COUNT
} kDataTypes;
class MySdk2Client : public ISdkDataListener
{
public:
// Constructor
MySdk2Client() : m_acceptData(false)
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
m_dataFiles[i] = NULL;
}
}
// Destructor, must close the data files
~MySdk2Client()
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
if (m_dataFiles[i]) fclose(m_dataFiles[i]);
}
}
virtual void SdkDataHasArrived(sFrameOfData* data);
virtual bool AcceptingSdkData() const { return m_acceptData; }
bool Connect(const char* serverIP, const char* clientIP, int maxFrames);
// Have we received all the frames required
bool IsFinished() const { return m_frameCount >= m_maxFrames; }
// Unregister ourselves from the EvartSdk2Interface object
void Disconnect()
{
m_sdk.SetDataListener(NULL);
m_sdk.Uninitialize();
}
// Create a file for the given data type
bool CreateDataFile(int dataType, const char* filename)
{
bool rc = false;
if (dataType >= 0 && dataType < DATA_TYPE_COUNT)
{
m_dataFiles[dataType] = fopen(filename, "w");
rc = (m_dataFiles[dataType] != NULL);
}
return rc;
}
private:
bool m_acceptData;
int m_frameCount;
int m_maxFrames;
FILE* m_dataFiles[DATA_TYPE_COUNT];
EvartSdk2Interface m_sdk;
void WriteFileHeader(int dataType, sBodyDefs* bodyDefs);
void WriteFrame(sFrameOfData* data);
void WriteIdentifiedHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteUnidentifiedHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteSegmentHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteDofHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteAnalogHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteForceHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteIdentifiedFrame(FILE* fp, sFrameOfData* data);
void WriteUnidentifiedFrame(FILE* fp, sFrameOfData* data);
void WriteSegmentFrame(FILE* fp, sFrameOfData* data);
void WriteDofFrame(FILE* fp, sFrameOfData* data);
void WriteAnalogFrame(FILE* fp, sFrameOfData* data);
void WriteForceFrame(FILE* fp, sFrameOfData* data);
};
// CConnectDlg message handlers
void CConnectDlg::OnBnClickedOk()
{
CString m_Eipaddress;
GetDlgItem( IDC_EDT_EIPADDRESS )->GetWindowText( m_Eipaddress);
CString m_Cipaddress;
GetDlgItem( IDC_EDT_CIPADDRESS )->GetWindowText( m_Cipaddress);
CString m_NOFTR;
GetDlgItem( IDC_EDT_NOFTR )->GetWindowText( m_NOFTR);
{
MySdk2Client sdkClient;
// Try to connect to the given EVaRT SDK2 server
if (sdkClient.Connect(m_Eipaddress, m_Cipaddress,atoi(m_NOFTR)))
{
m_Status.SetWindowText("Connected");
// Just wait until we've received the required number of frames
while (sdkClient.IsFinished() == false)
{
Sleep(1000);
}
sdkClient.Disconnect();
}
else
{
m_Status.SetWindowText("Could not connect to EVaRT System");
}
}
}
// This is called for each frame of data received by the SDK2.
// The pointer to data is "hot", so if it needs to be stored
// for later use, use EvartSdk2Interface::CopyFrame() to make a copy.
void MySdk2Client::SdkDataHasArrived(sFrameOfData* data)
{
WriteFrame(data);
// Stop accepting frames of data once we reach the number set by the user on the command line
if (++m_frameCount == m_maxFrames)
{
m_acceptData = false;
}
if (m_frameCount % 10 == 0)
{
*****This is where i need to put the code to update the m_NOFR edit box******
}
}
// Initialize the EVaRT SDK2
// Query list of objects being tracked by EVaRT
// Write out data file header
bool MySdk2Client::Connect(const char* serverIP, const char* clientIP, int maxFrames)
{
bool rc;
sBodyDefs* evartObjects = NULL;
m_maxFrames = maxFrames;
m_frameCount = 0;
// Initialize the EVaRT SDK2
rc = m_sdk.Initialize(clientIP, serverIP);
// Query the list of objects that EVaRT is currently tracking
evartObjects = m_sdk.GetBodyDefinitions();
if (rc && evartObjects)
{
#if WRITE_IDENTIFIED_MKRS
if (CreateDataFile(IDENTIFIED_MKRS, "named_mkrs.csv"))
{
WriteFileHeader(IDENTIFIED_MKRS, evartObjects);
}
#endif
#if WRITE_UNIDENTIFIED_MKRS
if (CreateDataFile(UNIDENTIFIED_MKRS, "unnamed_mkrs.csv"))
{
WriteFileHeader(UNIDENTIFIED_MKRS, evartObjects);
}
#endif
#if WRITE_SEGMENT_DATA
if (CreateDataFile(SEGMENT_DATA, "segment_data.csv"))
{
WriteFileHeader(SEGMENT_DATA, evartObjects);
}
#endif
#if WRITE_DOF_DATA
if (CreateDataFile(DOF_DATA, "dof_data.csv"))
{
WriteFileHeader(DOF_DATA, evartObjects);
}
#endif
#if WRITE_ANALOG_DATA
if (CreateDataFile(ANALOG_DATA, "analog_data.csv"))
{
WriteFileHeader(ANALOG_DATA, evartObjects);
}
#endif
#if WRITE_FORCE_DATA
if (CreateDataFile(FORCE_DATA, "force_data.csv"))
{
WriteFileHeader(FORCE_DATA, evartObjects);
}
#endif
// Register ourselves as a listener
m_sdk.SetDataListener(this);
// We are now ready to accept frames of data from EVaRT
m_acceptData = true;
}
else
{
rc = false;
}
// Free memory for the EVaRT body definitions
m_sdk.FreeBodyDefinitions(evartObjects);
return rc;
}
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
What I told you is still correct. If you want the object of type "MySdk2Client" to which the method "SdkDataHasArrived" belong to update the dialog, this object need to know about the dialog.
Add a pointer to your class:
Code:
CConnectDlg* m_pDialog;
This should probably be initialised in the constructor or something like that:
Code:
MySdk2Client(CConnectDlg* pDialog) : m_acceptData(false) ; m_pDialog(pDialog)
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
m_dataFiles[i] = NULL;
}
}
From that you can call a method from the dialog that will update the edit box as I explained before.
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
Elrond
What I told you is still correct. If you want the object of type "MySdk2Client" to which the method "SdkDataHasArrived" belong to update the dialog, this object need to know about the dialog.
Add a pointer to your class:
Code:
CConnectDlg* m_pDialog;
This should probably be initialised in the constructor or something like that:
Code:
MySdk2Client(CConnectDlg* pDialog) : m_acceptData(false) ; m_pDialog(pDialog)
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
m_dataFiles[i] = NULL;
}
}
From that you can call a method from the dialog that will update the edit box as I explained before.
Hi Elrod, it is still not working, im getting even more confussed now, and i now have 8 errors instead of 2, would it be possible for you to just edit the code in the places that need it and then re post it here.
then I will be able to see exactly whats going on.
sorry for being a pain.
Regards
Steph
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Give me the list of errors and we'll see what we can do...
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
I put the following in the header file:
Code:
class CConnectDlg : public CDialog
{
DECLARE_DYNAMIC(CConnectDlg)
public:
CConnectDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CConnectDlg();
// Dialog Data
enum { IDD = IDD_CONNECT };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CConnectDlg* m_pDialog;
CString m_NOFTR;
CString m_NOFR;
DWORD m_Eipaddress;
DWORD m_Cipaddress;
afx_msg void OnBnClickedOk();
CStatic m_Status;
};
And made changed to:
Code:
lass MySdk2Client : public ISdkDataListener
{
public:
// Constructor
MySdk2Client(CConnectDlg* pDialog) : m_acceptData(false) ; m_pDialog(pDialog)
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
m_dataFiles[i] = NULL;
}
}
the error codes are:
error C2969: syntax error : ';' : expected member function definition to end with '}'
error C2061: syntax error : identifier 'pDialog'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
warning C4183: 'm_pDialog': missing return type; assumed to be a member function returning 'int'
error C2059: syntax error : 'inline function header'
error C2630: ';' found in what should be a comma-separated list
error C2512: 'MySdk2Client' : no appropriate default constructor available
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
I think what is confusing is that there is two ways to update a edit or static text box.
Method 1:
Use a CString. With a CString you set it and then when UpdateData is called, the CString gets copied into the control. The other way around to get the control into the CString.
Method 2:
Use a Control. Declare it as CEdit or CStatic, then use DDX_Control in the exchange. That way you don't need UpdateData, and you can call all the control methods, like SetWindowText.
I personally use the second method, gives a lot more control (no pun intended) over what you are doing.
-Erik
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
I think pretty much all the errors you got come from a typo from my side. You need to put a coma rather than a semicolon int the initialisation list, before "m_pDialog"
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
Elrond
I think pretty much all the errors you got come from a typo from my side. You need to put a coma rather than a semicolon int the initialisation list, before "m_pDialog"
I put the coma in and now i have 2 errors:
error C2614: 'MySdk2Client' : illegal member initialization: 'm_pDialog' is not a base or member
error C2512: 'MySdk2Client' : no appropriate default constructor available
Hi erik, thanks for your input, would it be possible for you to show me how to do your method 2 with the code i have posted above.
I am really new to programming and it is a lot easier if i see it implemented into my code and then I am able to understand what is going on.
Thanks again for all your help
Regards
Steph
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
In my message with the typo, there was a first piece of code. It is the declaration of m_pDialog that you need to add to your class. Then it will know about it.
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
Elrond
In my message with the typo, there was a first piece of code. It is the declaration of m_pDialog that you need to add to your class. Then it will know about it.
I did put that in, thats why I showed you the header file:
Here it is again have i put it in the correct place:
Header file:
Code:
#pragma once
#include "afxwin.h"
// CConnectDlg dialog
class CConnectDlg : public CDialog
{
DECLARE_DYNAMIC(CConnectDlg)
public:
CConnectDlg(CWnd* pParent = NULL);// standard constructor
virtual ~CConnectDlg();
CConnectDlg* m_pDialog;
// Dialog Data
enum { IDD = IDD_CONNECT };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CString m_NOFTR;
CString m_NOFR;
DWORD m_Eipaddress;
DWORD m_Cipaddress;
afx_msg void OnBnClickedOk();
CStatic m_Status;
};
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
Steph86
Hi erik, thanks for your input, would it be possible for you to show me how to do your method 2 with the code i have posted above.
It looks like you know about it, you are doing it with CStatic with your m_Status. Just do the exact same, except with CEdit, to do an edit box. Remove the CString, it is best to only do one type of exchange at a time (although you CAN to both if you want). Just do a m_MyControl.GetWindowText(sString), to fill in the string when you want to read it.
-Erik
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
egawtry
It looks like you know about it, you are doing it with CStatic with your m_Status. Just do the exact same, except with CEdit, to do an edit box. Remove the CString, it is best to only do one type of exchange at a time (although you CAN to both if you want). Just do a m_MyControl.GetWindowText(sString), to fill in the string when you want to read it.
-Erik
Hi Erik, I have already tried what you suggested but it does not work, I just tried it again to make sure and the same thing happens.
I created a new control cedit called m_Number, and put the code as follows:
Code:
void MySdk2Client::SdkDataHasArrived(sFrameOfData* data)
{
WriteFrame(data);
// Stop accepting frames of data once we reach the number set by the user on the command line
if (++m_frameCount == m_maxFrames)
{
m_acceptData = false;
}
if (m_frameCount % 10 == 0)
{
m_Number.SetWindowText("%d\r", m_frameCount);
}
But i get the following errors just like before, this is what Elrond is trying to help me overcome.
error C2065: 'm_Number' : undeclared identifier
error C2228: left of '.GetWindowTextA' must have class/struct/union
The reason i think its happening is because the m_Number is in:
Code:
void CConnectDlg::OnBnClickedOk()
and its trying to read it in:
Code:
void MySdk2Client::SdkDataHasArrived(sFrameOfData* data)
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
You have put the declaration
Code:
CConnectDlg* m_pDialog;
into the wrong class.
It's MySdk2Client that needs to know about the dialog to be able to update the dialogs's data.
Kurt
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
Steph86
Hi Erik, I have already tried what you suggested but it does not work, I just tried it again to make sure and the same thing happens.
I created a new control cedit called m_Number, and put the code as follows: ...
But i get the following errors just like before, this is what Elrond is trying to help me overcome.
error C2065: 'm_Number' : undeclared identifier
error C2228: left of '.GetWindowTextA' must have class/struct/union
1. Did you put the "CEdit m_Number;" into your class declaration?
2. Did you add "DDX_Control(pDX, IDC_NUMBER, m_Number);" into the exchange?
Once you do that, there is no reason for them not to exist.
Also, make sure they are in the same class as ZuK suggests.
-Erik
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
ZuK
You have put the declaration
Code:
CConnectDlg* m_pDialog;
into the wrong class.
It's MySdk2Client that needs to know about the dialog to be able to update the dialogs's data.
Kurt
Thanks Zuk, I just put that in like this:
Code:
class MySdk2Client : public ISdkDataListener
{
public:
CConnectDlg* m_pDialog;
// Constructor
MySdk2Client(CConnectDlg* pDialog) : m_acceptData(false) , m_pDialog(pDialog)
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
m_dataFiles[i] = NULL;
}
}
// Destructor, must close the data files
~MySdk2Client()
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
if (m_dataFiles[i]) fclose(m_dataFiles[i]);
}
}
// Required method to implement the ISdkDataListener interface.
// Once we register ourselves with an EvartSdk2Interface object,
// this method will be called whenever a frame of data arrives from
// EVaRT.
virtual void SdkDataHasArrived(sFrameOfData* data);
// Required method to implement the ISdkDataListener interface.
// This should return true if frames of data are currently being
// accepted, and false if you do not want to receive frames of data.
virtual bool AcceptingSdkData() const { return m_acceptData; }
// Connect to the EVaRT SDK2 running on "serverIP" using the NIC in
// our client machine with IP address "clientIP"; maxFrames is the number
// of frames to write to the data file before exiting.
bool Connect(const char* serverIP, const char* clientIP, int maxFrames);
// Have we received all the frames required
bool IsFinished() const { return m_frameCount >= m_maxFrames; }
// Unregister ourselves from the EvartSdk2Interface object
void Disconnect()
{
m_sdk.SetDataListener(NULL);
m_sdk.Uninitialize();
}
// Create a file for the given data type
bool CreateDataFile(int dataType, const char* filename)
{
bool rc = false;
if (dataType >= 0 && dataType < DATA_TYPE_COUNT)
{
m_dataFiles[dataType] = fopen(filename, "w");
rc = (m_dataFiles[dataType] != NULL);
}
return rc;
}
private:
bool m_acceptData;
int m_frameCount;
int m_maxFrames;
FILE* m_dataFiles[DATA_TYPE_COUNT];
EvartSdk2Interface m_sdk;
void WriteFileHeader(int dataType, sBodyDefs* bodyDefs);
void WriteFrame(sFrameOfData* data);
void WriteIdentifiedHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteUnidentifiedHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteSegmentHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteDofHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteAnalogHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteForceHeader(FILE* fp, sBodyDefs* bodyDefs);
void WriteIdentifiedFrame(FILE* fp, sFrameOfData* data);
void WriteUnidentifiedFrame(FILE* fp, sFrameOfData* data);
void WriteSegmentFrame(FILE* fp, sFrameOfData* data);
void WriteDofFrame(FILE* fp, sFrameOfData* data);
void WriteAnalogFrame(FILE* fp, sFrameOfData* data);
void WriteForceFrame(FILE* fp, sFrameOfData* data);
};
now i only have one error left:
error C2512: 'MySdk2Client' : no appropriate default constructor available
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
Steph86
now i only have one error left
Looks like MySdk2Client needs to have a default constructor. If that is so the you will have to add a SetDialog() member
something like
Code:
class MySdk2Client : public ISdkDataListener
{
public:
CConnectDlg* m_pDialog;
// Constructor
MySdk2Client(CConnectDlg* pDialog = 0) : m_acceptData(false) , m_pDialog(pDialog)
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
m_dataFiles[i] = NULL;
}
}
void SetDialog( CConnectDlg* pDialog ) { m_pDialog = pDialog; }
and add a call to SetDialog() after construction of the MySdk2Client.
Kurt
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
ZuK
Looks like MySdk2Client needs to have a default constructor. If that is so the you will have to add a SetDialog() member
something like
Code:
class MySdk2Client : public ISdkDataListener
{
public:
CConnectDlg* m_pDialog;
// Constructor
MySdk2Client(CConnectDlg* pDialog = 0) : m_acceptData(false) , m_pDialog(pDialog)
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
m_dataFiles[i] = NULL;
}
}
void SetDialog( CConnectDlg* pDialog ) { m_pDialog = pDialog; }
and add a call to SetDialog() after construction of the MySdk2Client.
Kurt
Hi zuk, I done exactly as you said:
Code:
class MySdk2Client : public ISdkDataListener
{
public:
CConnectDlg* m_pDialog;
// Constructor
MySdk2Client(CConnectDlg* pDialog = 0) : m_acceptData(false) , m_pDialog(pDialog)
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
m_dataFiles[i] = NULL;
}
}
void SetDialog( CConnectDlg* pDialog ) { m_pDialog = pDialog; }
// Destructor, must close the data files
~MySdk2Client()
{
for (int i = 0; i < DATA_TYPE_COUNT; i++)
{
if (m_dataFiles[i]) fclose(m_dataFiles[i]);
}
}
and when i compile i still get the same errors:
error C2065: 'm_NOFR' : undeclared identifier
error C2228: left of '.SetWindowTextA' must have class/struct/union
It still can't find m_NOFR in:
Code:
void MySdk2Client::SdkDataHasArrived(sFrameOfData* data)
{
WriteFrame(data);
// Stop accepting frames of data once we reach the number set by the user on the command line
if (++m_frameCount == m_maxFrames)
{
m_acceptData = false;
}
if (m_frameCount % 10 == 0)
{
m_NOFR.SetWindowText("%d\r", m_frameCount);
}
}
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
m_NOFR is not a member of MySdk2Client.
It would have to be
Code:
m_pDialog->m_NOFR.SetWindowText("%d\r", m_frameCount);
Guess this way you will get rid of the compile errors. Now you will have to struggle with runtime errors.
Kurt
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Steph86, in my opinion you would be further ahead by putting this project aside for a day or two and spend the time working on an MFC tutorial.
Probably the best tutorial to start out with is the 'Scribble' tutorial.
It walks you through the steps to build a simple drawing app, but more importantly explains the MFC hows and whys along the way.
Based on your repeated questions covering the basics, working through the tutorial would give you the foundation necessary to get on with your real program.
Read the instructions for getting the scribble sample files:
Visual Studio 2008
http://msdn.microsoft.com/en-us/library/f35t8fts.aspx
Visual Studio 6.0
http://msdn.microsoft.com/en-us/libr...27(VS.60).aspx
Working through this tutorial is truly worth it.
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
ZuK
m_NOFR is not a member of MySdk2Client.
It would have to be
Code:
m_pDialog->m_NOFR.SetWindowText("%d\r", m_frameCount);
Guess this way you will get rid of the compile errors. Now you will have to struggle with runtime errors.
Kurt
Thanks for your time zuk,
now i get a different error:
error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,StringTraits>'
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
Quote:
Originally Posted by
Arjay
Steph86, in my opinion you would be further ahead by putting this project aside for a day or two and spend the time working on an MFC tutorial.
Probably the best tutorial to start out with is the 'Scribble' tutorial.
It walks you through the steps to build a simple drawing app, but more importantly explains the MFC hows and whys along the way.
Based on your repeated questions covering the basics, working through the tutorial would give you the foundation necessary to get on with your real program.
Read the instructions for getting the scribble sample files:
Visual Studio 2008
http://msdn.microsoft.com/en-us/library/f35t8fts.aspx
Visual Studio 6.0
http://msdn.microsoft.com/en-us/libr...27(VS.60).aspx
Working through this tutorial is truly worth it.
Thanks Arjay for your advice i'll get cracking on that asap.
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
If you have trouble locating the source or working through the tutorial steps, please start a new topic.
-
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
As I said multiple times, m_NOFR is not a window, it is a string, so you should use the method Format and not SetWindowText. But as you also have to update the data after that, it would be even better to put that in a method of CConnectDlg.
But in my opinion, due to the fact that you didn't understand that m_NOFR could not be accessed without using an instant of the dialog class, you should even take more time to understand the basics of object oriented programming and some basic of C++, even before you start working on the MFC. I think it will be hard for you to get the MFC and all that if you don't have some of the basics first. :)