Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving Text from an Edit Box

Status
Not open for further replies.

thebarslider

Programmer
Dec 21, 2001
80
GB
Dear All,

I have a dialog application and i wish to retrieve text from an Edit Box within it. I have set up a CEdit variable for the Edit box and used the function GetWindowText to place the text into a CString object.

I now wish to use the information within a different class (object) but the Object/String is in the CDialog class and i dont know how to reference the CDialog class/object in the call from my other object.

For example:

COneDlg::programmeName;

doesnt work

Neither does a call to a GetProgrammeName function within the Dialog class as i dont know what the dialog object is called? I'm not sure if i can do this anyway?
I have tried to use:

dlg.GetProgrammeName

but this doesnt work even though

CDialog dlg;
is defined in my main App and is included in the calling class.

I'm really stuck and need help.

Thank you to any one who can help me

Mark.
 
Mark,

You can't have a class named CDialog since it is already defined. If you try you will get a compile error: error C2011: 'CDialog' : 'class' type redefinition

>> CDialog dlg;
>> is defined in my main App and is included in the calling class.

That suggests that you are trying to use the CDialog base class in your application. There are so many things wrong with that I don’t know where to begin.

Since you don’t post the relevant code that your having a problem with it’s impossible to do anything be make wild guesses. Provide small relevant portions of code and include any compile or runtime error messages you get. If there are errors make sure and note exactly which line of code produces the error.

The bottom line is that a CDialog derived class is just a C++ class, so if you have an accessor method written correctly it will work, period.

Code:
class CMyDlg : public CDialog{
.... MFC stuff
protected:
   CString _mystring;
public:
   // accessor method that will ALWAYS return the value of
   // _mystring even if the value is WRONG
   const char* getMyString(){ return _mystring; }
};

So now in some code you do this:
Code:
CMyDlg dlg;
cout << dlg.getMyString() << endl;

You get exactly what is in that member variable.

-pete
 
Dear Pete,

Just to tidy my post up.

I have a class COneDlg with member variable:

CString ProgrammeName

i wish to access this from class: XML

i dont seem to have a COneDlg object anywhere?
 
>> i dont seem to have a COneDlg object anywhere?

Well i don't have one that i can lend you so i guess you'll have to make one for yourself.

Seriously... I don't know what help to give you at this point. If you need one, then create one i guess?

[bugeyed]
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top