CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 31
  1. #16
    Join Date
    Jul 2009
    Posts
    16

    Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String

    Quote Originally Posted by Elrond View Post
    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

  2. #17
    Join Date
    Oct 2001
    Location
    Dublin, Eire
    Posts
    880

    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.
    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

  3. #18
    Join Date
    Jul 2009
    Posts
    16

    Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String

    Quote Originally Posted by Elrond View Post
    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;
    };

  4. #19
    Join Date
    Oct 2005
    Location
    Minnesota, U.S.A.
    Posts
    680

    Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String

    Quote Originally Posted by Steph86 View Post
    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

  5. #20
    Join Date
    Jul 2009
    Posts
    16

    Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String

    Quote Originally Posted by egawtry View Post
    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)

  6. #21
    Join Date
    Oct 2002
    Location
    Austria
    Posts
    1,284

    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

  7. #22
    Join Date
    Oct 2005
    Location
    Minnesota, U.S.A.
    Posts
    680

    Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String

    Quote Originally Posted by Steph86 View Post
    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
    Last edited by egawtry; July 29th, 2009 at 12:09 PM.

  8. #23
    Join Date
    Jul 2009
    Posts
    16

    Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String

    Quote Originally Posted by ZuK View Post
    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

  9. #24
    Join Date
    Oct 2002
    Location
    Austria
    Posts
    1,284

    Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String

    Quote Originally Posted by Steph86 View Post
    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

  10. #25
    Join Date
    Jul 2009
    Posts
    16

    Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String

    Quote Originally Posted by ZuK View Post
    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);
    
    	}
    }

  11. #26
    Join Date
    Oct 2002
    Location
    Austria
    Posts
    1,284

    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

  12. #27
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    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.

  13. #28
    Join Date
    Jul 2009
    Posts
    16

    Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String

    Quote Originally Posted by ZuK View Post
    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>'

  14. #29
    Join Date
    Jul 2009
    Posts
    16

    Re: error C2039: 'SetWindowTextA' : is not a member of 'ATL::CStringT<BaseType,String

    Quote Originally Posted by Arjay View Post
    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.

  15. #30
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    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.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured