Results 1 to 3 of 3

Thread: Is This Question To HARD!!????

  1. #1

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    I have asked this question on many C++ forms and no one has been answer my question and I dont know if it's to hard (which I doubt) or I am not explaining it correctly or what. So this time I am going to give every piece of info I can.

    What I have a problem with is a pointer to a class. I have a FormView, SDI, MFC program. What I need is to be able to get the value from CString m_strTextOut. Maybe I am doing this wrong...Anyways

    Here is my class:

    Code:
    #if !defined(AFX_NAPAWAYVIEW_H__6CAC2E48_F85C_46C0_B13D_138D65352F6C__INCLUDED_)
    #define AFX_AWAYVIEW_H__6CAC2E48_F85C_46C0_B13D_138D65352F6C__INCLUDED_
    
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    
    class CAwayView : public CFormView
    {
    protected: // create from serialization only
    	CAwayView();
    	DECLARE_DYNCREATE(CAwayView)
    
    public:
    	//{{AFX_DATA(CAwayView)
    	enum{ IDD = IDD_AWAY_FORM };
    		// NOTE: the ClassWizard will add data members here
    	//}}AFX_DATA
    
    // Attributes
    public:
    	CAwayDoc* GetDocument();
    
    // Operations
    public:
    
    // Overrides
    	// ClassWizard generated virtual function overrides
    	//{{AFX_VIRTUAL(CNapAwayView)
    	public:
    	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
    	protected:
    	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    	virtual void OnInitialUpdate(); // called first time after construct
    	//}}AFX_VIRTUAL
    
    // Implementation
    public:
    	CString m_strTextOut;
    	virtual ~CAwayView();
    #ifdef _DEBUG
    	virtual void AssertValid() const;
    	virtual void Dump(CDumpContext& dc) const;
    #endif
    
    protected:
    
    // Generated message map functions
    protected:
    	//{{AFX_MSG(CNapAwayView)
    	afx_msg void OnbtnEXIT();
    	afx_msg void OnbtnCLEAR();
    	afx_msg void OnbtnOK();
    	//}}AFX_MSG
    	DECLARE_MESSAGE_MAP()
    };
    
    #ifndef _DEBUG  // debug version in AwayView.cpp
    inline CAwayDoc* CAwayView::GetDocument()
       { return (CAwayDoc*)m_pDocument; }
    #endif
    
    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
    
    #endif // !defined(AFX_AWAYVIEW_H__6CAC2E48_F85C_46C0_B13D_138D65352F6C__INCLUDED_)
    Now usually for any other class I would do (which I might be wrong):

    CAwayView tmp;
    CString strOut;
    strOut = tmp.m_strTextOut;

    But that does not work with this class because the constructor is private (I think). So after looking on the internet I found this:

    CAwayView* pView = (CAwayView*)m_viewList.GetHead();
    CString strOut;
    strOut = pView->m_strTextOut;

    Which worked fine for when I was saving the data but it does not work in any other class. Plus I have not idea what CAwayView* pView = (CAwayView*)m_viewList.GetHead(); does and it just looks wrong. I have tried everything I can think of but I cant make it work.

    What I need is to be able to get the value from m_strTextOut.

    Sorry this is so long but I need to get this to work, plus I am soooo frustrated.

    Can anyone help???

    Thanks
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    I havn't completley understood your class, there are a few to many macros for my liking.

    I don't think the constructor's the problem, I can't see anywhere where you've overloaded an assignment operator.

    something like this inside your class
    Code:
    CAwayView& operator = (CString& NewString)
    {
    
        // this code will be called when the user assigns 
        // a string to your class
    
    }

    put some cod3e in there

  3. #3

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    I am not sure I follow Sam

    Man I need to stop programing so late. I left two things out.

    First: I need to be able to get the value of m_strTextOut in a different class.

    And I left this out: my m_strTextOut gets it's value from a edit box during a DataExchange.

    With this new info is your idea still good? How would I call this string in another class.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


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