Click here to Skip to main content
15,887,375 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: About strings in c language Pin
dusty_dex16-Apr-13 6:25
dusty_dex16-Apr-13 6:25 
GeneralRe: About strings in c language Pin
Erudite_Eric16-Apr-13 7:33
Erudite_Eric16-Apr-13 7:33 
GeneralRe: About strings in c language Pin
dusty_dex16-Apr-13 9:19
dusty_dex16-Apr-13 9:19 
AnswerRe: About strings in c language Pin
Erudite_Eric16-Apr-13 4:54
Erudite_Eric16-Apr-13 4:54 
GeneralRe: About strings in c language Pin
H.Brydon16-Apr-13 5:16
professionalH.Brydon16-Apr-13 5:16 
GeneralRe: About strings in c language Pin
Erudite_Eric16-Apr-13 7:32
Erudite_Eric16-Apr-13 7:32 
AnswerRe: About strings in c language Pin
Marco Bertschi17-Apr-13 1:46
protectorMarco Bertschi17-Apr-13 1:46 
QuestionUnable to read in edit control data Pin
ForNow15-Apr-13 3:46
ForNow15-Apr-13 3:46 
Hi,

I have single line edit control as a member of a modal dialog box

I attach the CEdit object to the accompanying EDTITEXT resource via DDX_CONTROL

I then use DDX_TEXT to initialize a CString to read in the data However

When I invoke UpdateData(TRUE) to retrieve the text I get nothing

First the resource definition of dialog and control that are members

IDD_DIALOG4 DIALOGEX 0, 0, 316, 180
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Program Debug"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "Program Name",IDC_STATIC5,60,21,40,8
EDITTEXT IDC_EDIT3,60,40,50,14
LTEXT "Job Name",IDC_STATIC9,200,21,40,8
EDITTEXT IDC_EDIT4,200,40,50,14
LTEXT "Program Location",IDC_STATIC7,60,100,60,8
EDITTEXT IDC_EDIT5,60,120,50,14
LTEXT "Starting Address",IDC_STATIC8,200,100,60,8
EDITTEXT IDC_EDIT6,200,120,50,14
PUSHBUTTON "Process",IDC_PUSH,130,150,50,15
END

Next class definition for this dialog entry which has CString members to hold the data

C++
class Cprogdialog : public CDialog
{
	DECLARE_DYNAMIC(Cprogdialog)

public:
	void Process();
  	Cprogdialog(CWnd* pParent = NULL);	//	Cprogdialog();
//	CFileDialog myfile; 
	BOOL OnInitDialog();
	virtual ~Cprogdialog();
         CStatic  sprogname;                  // program label
	 CEdit    eprogname;                  // program object
	 CStatic  sjobname;
	 CEdit    ejobname;
	 CStatic  slocation;
	 CEdit    elocation;
	 CStatic  saddr;
	 CEdit    eaddr;
	 CButton  process;
	 CString  progname;
	 CString  jobname;
          CString  location;
	 CString   addr;
     
	 // program listing
// Dialog Data
//	enum { IDD = IDD_PROGDIALOG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
};


Then the DoDAtaExchange to attach the Cwnd type objects UpdateData(False) and reterive the
Data UpdateData(TRUE);

C++
void Cprogdialog::DoDataExchange(CDataExchange* pDX)
{
        CDialog::DoDataExchange(pDX);

        // Attach the Control to objects
        DDX_Control(pDX,IDC_STATIC5,sprogname);

        DDX_Control(pDX,IDC_EDIT3,eprogname);

        DDX_Control(pDX,IDC_STATIC9,sjobname);

        DDX_Control(pDX,IDC_EDIT4,ejobname);

       DDX_Control(pDX,IDC_STATIC7,slocation);

        DDX_Control(pDX,IDC_EDIT5,elocation);

        DDX_Control(pDX,IDC_STATIC8,saddr);

       DDX_Control(pDX,IDC_EDIT6,eaddr);

       DDX_Control(pDX,IDC_PUSH,process);

// ATTACH VARIABLES TO HOLD INFO

  DDX_Text(pDX,IDC_EDIT3,progname);

  DDX_Text(pDX,IDC_EDIT4,jobname);

  DDX_Text(pDX,IDC_EDIT5,location);

  DDX_Text(pDX,IDC_EDIT6,addr);

}

I invoke UpdateData(FALSE); to attach the CWnd type objects in the OninitDialog override

And when the user hits the "process" button I read in the data via UpdateData(TRUE);

I don't think I have to initialize the CString members I am using to retrieve the the data from the
EDTITEXT by using UpdateData(FALSE); and TRUE I Should be able to attach and reterive the data

regardless the progname and jobname CString members wich I use DDX_TEXT to initialize and reterive data don't have the data in them
QuestionRe: Unable to read in edit control data Pin
David Crow15-Apr-13 3:55
David Crow15-Apr-13 3:55 
AnswerRe: Unable to read in edit control data Pin
ForNow15-Apr-13 4:44
ForNow15-Apr-13 4:44 
AnswerRe: Unable to read in edit control data Pin
H.Brydon15-Apr-13 17:44
professionalH.Brydon15-Apr-13 17:44 
AnswerRe: Unable to read in edit control data Pin
Richard MacCutchan15-Apr-13 4:33
mveRichard MacCutchan15-Apr-13 4:33 
GeneralRe: Unable to read in edit control data Pin
ForNow15-Apr-13 4:45
ForNow15-Apr-13 4:45 
GeneralRe: Unable to read in edit control data Pin
Richard MacCutchan15-Apr-13 5:41
mveRichard MacCutchan15-Apr-13 5:41 
GeneralRe: Unable to read in edit control data Pin
ForNow15-Apr-13 5:57
ForNow15-Apr-13 5:57 
GeneralRe: Unable to read in edit control data Pin
Richard MacCutchan15-Apr-13 6:53
mveRichard MacCutchan15-Apr-13 6:53 
GeneralRe: Unable to read in edit control data Pin
H.Brydon15-Apr-13 17:51
professionalH.Brydon15-Apr-13 17:51 
GeneralRe: Unable to read in edit control data Pin
H.Brydon15-Apr-13 17:47
professionalH.Brydon15-Apr-13 17:47 
GeneralRe: Unable to read in edit control data Pin
Richard MacCutchan15-Apr-13 21:01
mveRichard MacCutchan15-Apr-13 21:01 
GeneralRe: Unable to read in edit control data Pin
Orjan Westin15-Apr-13 22:47
professionalOrjan Westin15-Apr-13 22:47 
GeneralRe: Unable to read in edit control data Pin
Richard MacCutchan15-Apr-13 23:05
mveRichard MacCutchan15-Apr-13 23:05 
GeneralRe: Unable to read in edit control data Pin
Orjan Westin16-Apr-13 0:14
professionalOrjan Westin16-Apr-13 0:14 
GeneralRe: Unable to read in edit control data Pin
H.Brydon16-Apr-13 4:56
professionalH.Brydon16-Apr-13 4:56 
GeneralRe: Unable to read in edit control data Pin
Richard MacCutchan15-Apr-13 23:47
mveRichard MacCutchan15-Apr-13 23:47 
AnswerRe: Unable to read in edit control data Pin
H.Brydon15-Apr-13 17:42
professionalH.Brydon15-Apr-13 17:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.