Solved

Writing to an edit box?

Posted on 1998-06-05
8
171 Views
Last Modified: 2013-11-19
I have a simple dialog app and have a browse button and I want the path of the FileDialog to be written into the edit box.  I have the path stored in a variable already but how do I associate the variable with the edit box.  Then after it is associated with the edit box, does it automatically write the value in when the variable is assigned?

thanks,
j. karau
0
Comment
Question by:karau
  • 3
  • 3
  • 2
8 Comments
 
LVL 3

Accepted Solution

by:
tma050898 earned 50 total points
ID: 1316069
Answer coming...
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1316070
To create a DDX "value" member variable associated with a control...

1. From ClassWizard, select the Member Variables tab
2. Using the Add Variable button, create a variable associated with the desired control
3. When you want to update the control's value (e.g., an edit control's text), assign a value to this member variable and call UpdateData(FALSE)

Tom

0
 

Author Comment

by:karau
ID: 1316071
I am sorry I should have mentioned that I am currently working in BC++ so I don't have class wizard.  I do have a DoDataExchange Function already written though, it looks like this:

void COptClass::DoDataExchange(CDataExchange* pDX) {
      CDialog::DoDataExchange(pDX);
        DDX_Text(pDX, IDC_SOUNDEDIT, m_TFile);
}

I think this is correct, where m_TFile is the name of a variable within my COptClass.  If I then call UpdateData(FALSE) after the FileDialog will this work?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Expert Comment

by:wyhjin
ID: 1316072
Hi, Man: We are dealing with MFC which stands for MICROSOFT Foundation Class, Not Borland.
0
 

Author Comment

by:karau
ID: 1316073
Borland supports MFC that is why I asked the question.  I just can't afford to purchase Visual C++ so I make do, and BC++ works GREAT, THANK YOU

j.karau
0
 
LVL 3

Expert Comment

by:tma050898
ID: 1316074
karau,

You've probably already figured this out since you graded the question. However, just to make sure that you understand a couple of things...

Yes, UpdateData will work from your Borland app because it is an MFC function. Actually, it is a member function of the CDialog class. Calling UpdateData(FALSE) will update the controls with the values of your DDX member variables. Calling UpdateData(TRUE) will update the DDX member variables with the values from the controls.

Since you are using Borland, the only difference (and once again it looks like you already know this) is that when using DDX, you have to manually code the DoDataExchange calls.

Lemme know if you need any more assistance.

Tom

0
 

Expert Comment

by:wyhjin
ID: 1316075
Following is how I deal with this kind of problem.
1. Get the CEdit pointer by calling GetDlgItem() function.
2. Build up an object of CString, which contains any information    I want to display in CEdit control.
3. Call SetWindowText(Name_of_the-CString) function of CWnd to    display the text embedded in the CString object.
4. check online help for detail of SetWindowText() function.

Any comments and suggestions are welcome.
wyhjin
0
 

Author Comment

by:karau
ID: 1316076
This has been even more helpful than I had imagined, Thank you both tma and wyhjin.

j. karau
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 108
Complete beginner needs help making a cron job 9 125
Window placement 17 87
Detect file exist or not 3 179
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question