-
July 28th, 2009, 06:09 AM
#1
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
-
July 28th, 2009, 06:13 AM
#2
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.
-
July 28th, 2009, 06:27 AM
#3
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
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
-
July 28th, 2009, 06:47 AM
#4
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...
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
July 28th, 2009, 08:31 AM
#5
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
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
-
July 28th, 2009, 10:16 AM
#6
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.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
July 28th, 2009, 12:30 PM
#7
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
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");
}
Last edited by Steph86; July 29th, 2009 at 10:35 AM.
-
July 29th, 2009, 03:15 AM
#8
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.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
July 29th, 2009, 08:10 AM
#9
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;
}
Last edited by Steph86; July 29th, 2009 at 08:17 AM.
-
July 29th, 2009, 08:30 AM
#10
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.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
July 29th, 2009, 09:04 AM
#11
Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String
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
-
July 29th, 2009, 09:19 AM
#12
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...
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
July 29th, 2009, 09:27 AM
#13
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
-
July 29th, 2009, 10:10 AM
#14
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
-
July 29th, 2009, 10:18 AM
#15
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"
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|